wxSQLite3 and SQLite3 as static libraries. Information share

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
Knows some wx things
Knows some wx things
Posts: 27
Joined: Thu Jun 25, 2009 2:43 am
Location: Portland, Oregon

wxSQLite3 and SQLite3 as static libraries. Information share

Post by webmasterpdx » Fri Jan 28, 2011 7:48 pm

Just some suggestions. It took me quite a while to figure out how to compile these objects as part of wxDevC++ and I wanted to share this information.

Finally, after much screwing around, I decided to build the source files wxSQLite3.cpp and SQLite3.c as part of my sqltest application. This demonstrates how to build them. You just use the same features to build them as libraries.

First, in wxDevC++ under MENU-Project-Project Options, it will pop up a window with various tabs.
Under the Parameters tab, I put the following in the Compiler window:

In the C++ Compiler window I put the following:

Note that the wxUSE_DYNAMIC_SQLITE3_LOAD is an instruction for wxSQLite3.cpp to not try to load SQLite3 as a DLL.

Finally, in the linker window I put the following:

These are just following the instructions in the link I was given here:

Next, in the Files tab, make sure that you click on the SQLite3.c file and uncheck the "Compile file as C++". This will ensure the use of ANSI gcc instead of g++. If you don't do this, you will get compile errors when converting void * to char *. This is OK in C, but not in C++.

Finally, under the Compiler tab, click on the Linker and turn generate debugging information to No instead of Yes.

I've found that you can run into problems generating debugging information for sqlite3, which can result in an infinite loop while linking the code. This will ensure that this doesn't happen.

Then click on OK to save your settings.

Finally, when doing the build, select MENU-Execute-Clean followed by MENU-Execute-Rebuild All, and this will rebuild everything.

I got a clean build and under bash, went to the Output/Mingw directory and did a chmod +x on the sqltest.exe (my executable), and to run it did a ./sqltest.exe and it ran just fine.

These tips should help anyone to build the wxSQLite3 code along with sqlite3. Note that I took the latest SQLite3 code and created a src directory under wxSQLite3/sqlite3 and got the amalgamated release of sqlite3 as a tar.gz.gz file and opened it with 7zip. I clicked it repeatedly until I got to the files. I selected all and extracted to that src directory. I then just took that sqlite3.c, sqlite3.h and sqlite3ext.h. I placed the .h files in my Dev-Cpp/include directory. If you build the static link library, just place it in libsqlite3.a under Dev-Cpp/lib.

Then, just follow the instructions for wxsqlite3.

Good Luck.

Post Reply