wxSQLite3, how to build SQLite without dll? Topic is solved
-
- Super wx Problem Solver
- Posts: 401
- Joined: Wed Sep 21, 2005 8:17 am
- Location: Rostov-on-Don, Southern Russia
wxSQLite3, how to build SQLite without dll?
Hi all.
I use wxSQLite3 successfully, perfect wrapper, but my executables requires sqlite.dll every time.... I read Readme.txt that explains how to use statically linked SQLite library on Windows, but it unclearly should I download sqlite-amalgamation-3_6_11.zip or sqlite-source-3_6_11.zip and how to compile and build wxSQLite3 step by step including Visual C++ 2008 EE compiler-linker settings.....
Is there anyone who did it before?
Thanks in advance.
I use wxSQLite3 successfully, perfect wrapper, but my executables requires sqlite.dll every time.... I read Readme.txt that explains how to use statically linked SQLite library on Windows, but it unclearly should I download sqlite-amalgamation-3_6_11.zip or sqlite-source-3_6_11.zip and how to compile and build wxSQLite3 step by step including Visual C++ 2008 EE compiler-linker settings.....
Is there anyone who did it before?
Thanks in advance.
Win XP HE SP3, Vista
Xubuntu 12.04 LTS
wxWidgets-2.9.5
wxWidgets-3.0.0
Xubuntu 12.04 LTS
wxWidgets-2.9.5
wxWidgets-3.0.0
-
- Super wx Problem Solver
- Posts: 401
- Joined: Wed Sep 21, 2005 8:17 am
- Location: Rostov-on-Don, Southern Russia
Now I compiled both sqlite3.c and sqlite3.h separately of my application, then I copied sqlite3.lib into \sqlite3\lib of my application catalog, rebuilded my solution and get 2 errors:
because of my code uses wxSQLite3 encryption I can't use "standard" sqlite3.dll and I can assume can't use standard sqlite3.lib too...
Code: Select all
Linking...
wxcode_msw28u_wxsqlite3.lib(wxsqlite3.obj) : error LNK2001: unresolved external symbol _sqlite3_rekey
wxcode_msw28u_wxsqlite3.lib(wxsqlite3.obj) : error LNK2001: unresolved external symbol _sqlite3_key
C:\Projects\PhoneBookLast\PhoneBookLast\Release\PhoneBookLast.exe : fatal error LNK1120: 2 unresolved externals
Win XP HE SP3, Vista
Xubuntu 12.04 LTS
wxWidgets-2.9.5
wxWidgets-3.0.0
Xubuntu 12.04 LTS
wxWidgets-2.9.5
wxWidgets-3.0.0
If you want to use the encryption extension included in the wxSQLite3 release you can't use the SQLite amalgamation unfortunately since the encryption extension is written in C++ while SQLite itself is written in C. Follow the instructions in the wxSQLite3 readme file to create a static SQLite library and and link wxSQLite3 against the resulting .lib file.Mojo wrote:Now I compiled both sqlite3.c and sqlite3.h separately of my application, then I copied sqlite3.lib into \sqlite3\lib of my application catalog, rebuilded my solution and get 2 errors:
because of my code uses wxSQLite3 encryption I can't use "standard" sqlite3.dll and I can assume can't use standard sqlite3.lib too...Code: Select all
Linking... wxcode_msw28u_wxsqlite3.lib(wxsqlite3.obj) : error LNK2001: unresolved external symbol _sqlite3_rekey wxcode_msw28u_wxsqlite3.lib(wxsqlite3.obj) : error LNK2001: unresolved external symbol _sqlite3_key C:\Projects\PhoneBookLast\PhoneBookLast\Release\PhoneBookLast.exe : fatal error LNK1120: 2 unresolved externals
Regards,
Ulrich
As Mojo said his code uses wxSQLite3 encryption so he needs to compile SQLite with encryption support.protocol wrote:No need to compile them separately, at least I never do.
Those two symbols are for sqlite encryption, if you don't need it you can disable wxsqlite encryption.
BTW, when I compile SQLite including my encryption extension I use the following SQLite relevant preprocessor defines:
THREADSAFE=1
SQLITE_SOUNDEX
SQLITE_ENABLE_COLUMN_METADATA
SQLITE_HAS_CODEC
SQLITE_SECURE_DELETE
SQLITE_ENABLE_FTS3
SQLITE_ENABLE_FTS3_PARENTHESIS
SQLITE_ENABLE_RTREE
SQLITE_CORE
If FTS3 and/or RTREE support is not needed the associated defines may be dropped from the list.
Regards,
Ulrich
-
- Super wx Problem Solver
- Posts: 401
- Joined: Wed Sep 21, 2005 8:17 am
- Location: Rostov-on-Don, Southern Russia
Thank you Ulrich, thank you protocol.
I tried to go several ways, but my app still takes sqlite3.dll, can't get what do I do wrong.....
I went this steps:
1. I downloaded sqlite-source-3_6_11.zip, it has a lot of *.c and *.h files, then I build all them as one static lib (except for shell.c and tclsqlite.c), I got SQLite3.lib (big file about 4.55Mb).
2. I copied that big file (SQLite3.lib) into wxSQLite3 \sqlite3\lib folder, then I rebuild wxSQLite3 as static lib, all went OK and I got wxcode_msw28u_wxsqlite3.lib (the size of 4.22 Mb).
3. Then I copied new wxcode_msw28u_wxsqlite3.lib into \lib\vc_lib catalog of my project and rebuided my project, all went OK, but when I launch my app..... it requires sqlite3.dll awful disappointment I got lost
What do I do wrong? I read Readme.txt and did all as it said...
I tried to go several ways, but my app still takes sqlite3.dll, can't get what do I do wrong.....
I went this steps:
1. I downloaded sqlite-source-3_6_11.zip, it has a lot of *.c and *.h files, then I build all them as one static lib (except for shell.c and tclsqlite.c), I got SQLite3.lib (big file about 4.55Mb).
2. I copied that big file (SQLite3.lib) into wxSQLite3 \sqlite3\lib folder, then I rebuild wxSQLite3 as static lib, all went OK and I got wxcode_msw28u_wxsqlite3.lib (the size of 4.22 Mb).
3. Then I copied new wxcode_msw28u_wxsqlite3.lib into \lib\vc_lib catalog of my project and rebuided my project, all went OK, but when I launch my app..... it requires sqlite3.dll awful disappointment I got lost
What do I do wrong? I read Readme.txt and did all as it said...
Win XP HE SP3, Vista
Xubuntu 12.04 LTS
wxWidgets-2.9.5
wxWidgets-3.0.0
Xubuntu 12.04 LTS
wxWidgets-2.9.5
wxWidgets-3.0.0
The size seems to be quite big. I get about 900 kb in release mode and about 2.5Mb in debug mode when using VC++ 2008 EE. So you seem to use different compiler/linker settings. Please compare the compiler command prompt displayable in the project properties dialog to the following:Mojo wrote:I went this steps:
1. I downloaded sqlite-source-3_6_11.zip, it has a lot of *.c and *.h files, then I build all them as one static lib (except for shell.c and tclsqlite.c), I got SQLite3.lib (big file about 4.55Mb).
Code: Select all
/I "..\src" /I "..\src\ext\fts3" /D "WIN32" /D "NDEBUG" /D "_LIB" /D "THREADSAFE=1" /D "SQLITE_SOUNDEX" /D "SQLITE_ENABLE_COLUMN_METADATA" /D "SQLITE_HAS_CODEC" /D "SQLITE_SECURE_DELETE" /D "SQLITE_ENABLE_FTS3" /D "SQLITE_ENABLE_FTS3_PARENTHESIS" /D "SQLITE_ENABLE_RTREE" /D "SQLITE_CORE" /D "_VC80_UPGRADE=0x0600" /D "_MBCS" /FD /EHsc /MD /Fp".\Release/sqlite3lib.pch" /Fo".\Release/" /Fd".\Release/" /W3 /nologo /c /TP /errorReport:prompt
This should produce a library not requiring the SQLite DLL - if you didn't change the default setting of the precompiler define wxUSE_DYNAMIC_SQLITE3_LOAD (which should be set to 0).Mojo wrote:2. I copied that big file (SQLite3.lib) into wxSQLite3 \sqlite3\lib folder, then I rebuild wxSQLite3 as static lib, all went OK and I got wxcode_msw28u_wxsqlite3.lib (the size of 4.22 Mb).
It seems that the linker references the wrong library either when building wxSQLite3 or your own application. Please post the command prompts of the compiler and the linker. This should give a hint what's going wrong.Mojo wrote:3. Then I copied new wxcode_msw28u_wxsqlite3.lib into \lib\vc_lib catalog of my project and rebuided my project, all went OK, but when I launch my app..... it requires sqlite3.dll awful disappointment I got lost
What do I do wrong? I read Readme.txt and did all as it said...
Regards,
Ulrich
I agree with utelle, in that you need to review your linker settings.
But again, I don't have any issues building, and my config is much simpler.
Do you have to build external libs?
But again, I don't have any issues building, and my config is much simpler.
Do you have to build external libs?
- Attachments
-
- I add the wxsqlite and sqlite3 files to the proj directly, no need for static libs to configure.
- vs-proj-tree.png (7.08 KiB) Viewed 11376 times
-
- Super wx Problem Solver
- Posts: 401
- Joined: Wed Sep 21, 2005 8:17 am
- Location: Rostov-on-Don, Southern Russia
Thank you Ulrich, thank you protocol.
Ulrich's post very helped me
My compiler settings are:
My linker settings are:
Now I got SQLite3.lib that has size of 379 Kb, this is normally as I guess.
But I assume I have to tie somehow wxSQLite3 encryption feature and SQLite3.lib ...
I added to SQLite3.lib proj codec-folder from wxSQLite3 archive and tried to rebuild SQLite3.lib with encryption support, but I got error:
While 'pager.c' is linked OK, cause I builded SQLite3.lib without encryption feature successfully.
I guess it takes somehow particular compiler and linker settings for encryption support....
I am not sure how to choose right way, I added codec-folder into C/C++ ->General->Additional Include Directories, and there I added before include-folder with SQLite3 header-files (I divided SQLite3 into two catalogs 'include' and 'src').
What settings do I lack else?
Thanks in advance.
Ulrich's post very helped me
I set all my compiler and linker settings as Ulrich kindly provided above.utelle wrote:..... Please compare the compiler command prompt displayable in the project properties dialog to the following:
Do you see differences? If so, which? ...........Code: Select all
/I "..\src" /I "..\src\ext\fts3" /D "WIN32" /D "NDEBUG" /D "_LIB" /D "THREADSAFE=1" /D "SQLITE_SOUNDEX" /D "SQLITE_ENABLE_COLUMN_METADATA" /D "SQLITE_HAS_CODEC" /D "SQLITE_SECURE_DELETE" /D "SQLITE_ENABLE_FTS3" /D "SQLITE_ENABLE_FTS3_PARENTHESIS" /D "SQLITE_ENABLE_RTREE" /D "SQLITE_CORE" /D "_VC80_UPGRADE=0x0600" /D "_MBCS" /FD /EHsc /MD /Fp".\Release/sqlite3lib.pch" /Fo".\Release/" /Fd".\Release/" /W3 /nologo /c /TP /errorReport:prompt
My compiler settings are:
Code: Select all
/I "include" /D "WIN32" /D "NDEBUG" /D "_LIB" /D "THREADSAFE=1" /D "SQLITE_SOUNDEX" /D "SQLITE_ENABLE_COLUMN_METADATA" /D "SQLITE_HAS_CODEC" /D "SQLITE_SECURE_DELETE" /D "SQLITE_CORE" /FD /EHsc /MD /Fo"Release\" /Fd"Release\vc90.pdb" /W3 /nologo /c /TP /errorReport:prompt
Code: Select all
/OUT:"C:\Projects\SQLite3\SQLite3\Release\SQLite3.lib" /NOLOGO /LTCG
Now I got SQLite3.lib that has size of 379 Kb, this is normally as I guess.
But I assume I have to tie somehow wxSQLite3 encryption feature and SQLite3.lib ...
I added to SQLite3.lib proj codec-folder from wxSQLite3 archive and tried to rebuild SQLite3.lib with encryption support, but I got error:
Code: Select all
Compiling...
pager_secure.c
.\codec\pager_secure.c(1) : fatal error C1083: Cannot open include file: 'pager.c': No such file or directory
I guess it takes somehow particular compiler and linker settings for encryption support....
I am not sure how to choose right way, I added codec-folder into C/C++ ->General->Additional Include Directories, and there I added before include-folder with SQLite3 header-files (I divided SQLite3 into two catalogs 'include' and 'src').
What settings do I lack else?
Thanks in advance.
Win XP HE SP3, Vista
Xubuntu 12.04 LTS
wxWidgets-2.9.5
wxWidgets-3.0.0
Xubuntu 12.04 LTS
wxWidgets-2.9.5
wxWidgets-3.0.0
-
- Super wx Problem Solver
- Posts: 401
- Joined: Wed Sep 21, 2005 8:17 am
- Location: Rostov-on-Don, Southern Russia
Now I got another error:
My compiler command prompt settings are:
Librarian setting still same:
Something goes wrong with encryption ....[/code]
Code: Select all
Generating Code...
Compiling...
codecext.cpp
c:\projects\sqlite3\sqlite3\codec\codec.h(24) : fatal error C1083: Cannot open include file: '../sqliteInt.h': No such file or directory
codec.cpp
c:\projects\sqlite3\sqlite3\codec\codec.h(24) : fatal error C1083: Cannot open include file: '../sqliteInt.h': No such file or directory
rijndael.cpp
My compiler command prompt settings are:
Code: Select all
/I "..\src" /I "..\include" /I "include" /I "src" /I "codec" /I "..\codec" /D "WIN32" /D "NDEBUG" /D "_LIB" /D "THREADSAFE=1" /D "SQLITE_SOUNDEX" /D "SQLITE_ENABLE_COLUMN_METADATA" /D "SQLITE_HAS_CODEC=1" /D "SQLITE_SECURE_DELETE" /D "SQLITE_CORE" /FD /EHsc /MD /Fo"Release\\" /Fd"Release\vc90.pdb" /W3 /nologo /c /TP /errorReport:prompt
Code: Select all
/OUT:"C:\Projects\SQLite3\SQLite3\Release\SQLite3.lib" /NOLOGO /LTCG
Win XP HE SP3, Vista
Xubuntu 12.04 LTS
wxWidgets-2.9.5
wxWidgets-3.0.0
Xubuntu 12.04 LTS
wxWidgets-2.9.5
wxWidgets-3.0.0
-
- Super wx Problem Solver
- Posts: 401
- Joined: Wed Sep 21, 2005 8:17 am
- Location: Rostov-on-Don, Southern Russia
Bingo! I did it
I placed codec folder into include (the catalog of SQLite3 header files) all compiled OK, just some warnings:
But SQLite3.lib works OK, my app doesn't take sqlite3.dll any more and encryption works OK
Good bye Builder C++, good bye MFC, I am fan of wxWidgets now )
Thank you Ulrich and protocol, wxSQLite3 is splendid! )
I placed codec folder into include (the catalog of SQLite3 header files) all compiled OK, just some warnings:
Code: Select all
Compiling...
codecext.cpp
c:\projects\sqlite3\sqlite3\include\codec\codec.h(33) : warning C4005: 'PAGER_MJ_PGNO' : macro redefinition
c:\projects\sqlite3\sqlite3\include\pager.h(55) : see previous definition of 'PAGER_MJ_PGNO'
codec.cpp
c:\projects\sqlite3\sqlite3\include\codec\codec.h(33) : warning C4005: 'PAGER_MJ_PGNO' : macro redefinition
c:\projects\sqlite3\sqlite3\include\pager.h(55) : see previous definition of 'PAGER_MJ_PGNO'
rijndael.cpp
Generating Code...
Creating library...
pager.obj : warning LNK4006: _sqlite3PagerSetCachesize already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerSetSafetyLevel already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerSetBusyhandler already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerSetReiniter already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerSetPagesize already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerTempSpace already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerMaxPageCount already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerReadFileheader already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerPagecount already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerTruncateImage already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerClose already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerRef already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerOpen already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerAcquire already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerLookup already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerUnref already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerBegin already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerWrite already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerDontWrite already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerSync already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerCommitPhaseOne already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerCommitPhaseTwo already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerRollback already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerIsreadonly already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerRefcount already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerPageRefcount already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerIsMemdb already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerOpenSavepoint already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerSavepoint already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerFilename already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerVfs already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerFile already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerJournalname already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerNosync already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerSetCodec already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerMovepage already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerGetData already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerGetExtra already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerLockingMode already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerJournalMode already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerJournalSizeLimit already defined in pager_secure.obj; second definition ignored
pager.obj : warning LNK4006: _sqlite3PagerBackupPtr already defined in pager_secure.obj; second definition ignored
Build log was saved at "file://c:\Projects\SQLite3\SQLite3\Release\BuildLog.htm"
SQLite3 - 0 error(s), 44 warning(s)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
Good bye Builder C++, good bye MFC, I am fan of wxWidgets now )
Thank you Ulrich and protocol, wxSQLite3 is splendid! )
Win XP HE SP3, Vista
Xubuntu 12.04 LTS
wxWidgets-2.9.5
wxWidgets-3.0.0
Xubuntu 12.04 LTS
wxWidgets-2.9.5
wxWidgets-3.0.0
Right. Of course you have to add the files in the sqlite3/src/codec subdirectory to the project for building SQLite.Mojo wrote:But I assume I have to tie somehow wxSQLite3 encryption feature and SQLite3.lib ...
Well, I quote the relevant sentence from the readme file coming with wxSQLite3:Mojo wrote:I added to SQLite3.lib proj codec-folder from wxSQLite3 archive and tried to rebuild SQLite3.lib with encryption support, but I got error:
While 'pager.c' is linked OK, cause I builded SQLite3.lib without encryption feature successfully.Code: Select all
Compiling... pager_secure.c .\codec\pager_secure.c(1) : fatal error C1083: Cannot open include file: 'pager.c': No such file or directory
... Instead of compiling pager.c you need to compile the wrapper file pager_secure.c which includes the original unmodified file pager.c using a #include directive. Add the sources in subdirectory codec to the SQLite makefile, replace the reference to pager.c in the
makefile to pager_secure.c ...
The directory where all SQLite sources and headers reside has to be added as an additional include directory, too.Mojo wrote:I guess it takes somehow particular compiler and linker settings for encryption support....
I am not sure how to choose right way, I added codec-folder into C/C++ ->General->Additional Include Directories, and there I added before include-folder with SQLite3 header-files (I divided SQLite3 into two catalogs 'include' and 'src').
What settings do I lack else?
Regards,
Ulrich
The reason for all those warnings is that you included both, pager_secure.c and pager.c, in your project. Drop pager.c from your project (as it is included by pager_sevure.c) and the warnings will vanish.Mojo wrote:I placed codec folder into include (the catalog of SQLite3 header files) all compiled OK, just some warnings:Code: Select all
Compiling... codecext.cpp c:\projects\sqlite3\sqlite3\include\codec\codec.h(33) : warning C4005: 'PAGER_MJ_PGNO' : macro redefinition c:\projects\sqlite3\sqlite3\include\pager.h(55) : see previous definition of 'PAGER_MJ_PGNO' codec.cpp c:\projects\sqlite3\sqlite3\include\codec\codec.h(33) : warning C4005: 'PAGER_MJ_PGNO' : macro redefinition c:\projects\sqlite3\sqlite3\include\pager.h(55) : see previous definition of 'PAGER_MJ_PGNO' rijndael.cpp Generating Code... Creating library... pager.obj : warning LNK4006: _sqlite3PagerSetCachesize already defined in pager_secure.obj; second definition ignored ... SQLite3 - 0 error(s), 44 warning(s) ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
Although it works you should nevertheless follow the above recommendation.Mojo wrote:But SQLite3.lib works OK, my app doesn't take sqlite3.dll any more and encryption works OK
Regards,
Ulrich