wxSQLite3 compile problem Topic is solved

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
de
In need of some credit
In need of some credit
Posts: 2
Joined: Sun May 19, 2013 8:52 pm

wxSQLite3 compile problem

Post by de »

Hi everyone,

I am newcomer here, facing a wired problem with gcc (tdm version 4.7.1)

Code: Select all

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.7.1/lto-w
rapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../src/gcc-4.7.1/configure --build=x86_64-w64-mingw32 --enab
le-targets=all --enable-languages=c,c++,fortran,objc,obj-c++ --enable-libgomp --
enable-lto --enable-libstdcxx-debug --enable-version-specific-runtime-libs --ena
ble-fully-dynamic-string --with-gnu-ld --disable-werror --disable-nls --disable-
win32-registry --prefix=/mingw64tdm --with-local-prefix=/mingw64tdm --with-pkgve
rsion=tdm64-1 --with-bugurl=http://tdm-gcc.tdragon.net/bugs
Thread model: win32
gcc version 4.7.1 (tdm64-1)

Code: Select all

-------------- Clean: Release gcc in prototype (compiler: GNU GCC Compiler)---------------

Cleaned "prototype - Release gcc"

-------------- Build: Release gcc in prototype (compiler: GNU GCC Compiler)---------------

g++.exe -Wall -pipe -mthreads -Wno-attributes -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE   -D_UNICODE -D__WXMSW__   -IC:\wxWidgets-2.9.4\include -IC:\wxWidgets-2.9.4\contrib\include -IC:\sqlite-amalgamation-3071602 -IC:\wxWidgets-2.9.4\lib\gcc_lib\mswu -IC:\wxsqlite3-3.0.3\include -IC:\wxWidgets-2.9.4\include -IC:\wxWidgets-2.9.4\lib\gcc_lib\mswu  -c C:\Users\ma\Documents\projects\prototype\prototypeApp.cpp -o "obj\Release gcc\prototypeApp.o"
g++.exe -Wall -pipe -mthreads -Wno-attributes -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE   -D_UNICODE -D__WXMSW__   -IC:\wxWidgets-2.9.4\include -IC:\wxWidgets-2.9.4\contrib\include -IC:\sqlite-amalgamation-3071602 -IC:\wxWidgets-2.9.4\lib\gcc_lib\mswu -IC:\wxsqlite3-3.0.3\include -IC:\wxWidgets-2.9.4\include -IC:\wxWidgets-2.9.4\lib\gcc_lib\mswu  -c C:\Users\ma\Documents\projects\prototype\prototypeMain.cpp -o "obj\Release gcc\prototypeMain.o"
C:\Users\ma\Documents\projects\prototype\prototypeMain.cpp: In member function 'void prototypeFrame::OnAbout(wxCommandEvent&)':
C:\Users\ma\Documents\projects\prototype\prototypeMain.cpp:104:21: warning: unused variable 'db' [-Wunused-variable]
windres.exe -IC:\wxWidgets-2.9.4\include -IC:\wxWidgets-2.9.4\lib\gcc_lib\mswu -IC:\wxWidgets-2.9.4\include  -J rc -O coff -i C:\Users\ma\DOCUME~1\projects\PROTOT~1\resource.rc -o "obj\Release gcc\resource.res"
g++.exe -LC:\sqlite-amalgamation-3071602 -LC:\wxWidgets-2.9.4\lib\gcc_lib -LC:\wxsqlite3-3.0.3\lib\gcc_lib -LC:\wxWidgets-2.9.4\lib\gcc_lib  -o "bin\Release gcc\prototype.exe" "obj\Release gcc\prototypeApp.o" "obj\Release gcc\prototypeMain.o"  "obj\Release gcc\resource.res"  -mthreads  -lsqlite3 -lwxmsw29u_core -lwxbase29u -lwxpng -lwxjpeg -lwxtiff -lwxzlib -lwxregexu -lwxcode_msw29u_wxsqlite3 -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32  -mwindows
C:\wxsqlite3-3.0.3\lib\gcc_lib/libwxcode_msw29u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0x167): undefined reference to `sqlite3_result_text'
C:\wxsqlite3-3.0.3\lib\gcc_lib/libwxcode_msw29u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0x185): undefined reference to `sqlite3_free'
C:\wxsqlite3-3.0.3\lib\gcc_lib/libwxcode_msw29u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0x195): undefined reference to `sqlite3_free'
C:\wxsqlite3-3.0.3\lib\gcc_lib/libwxcode_msw29u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0x205): undefined reference to `sqlite3_free'
C:\wxsqlite3-3.0.3\lib\gcc_lib/libwxcode_msw29u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0x215): undefined reference to `sqlite3_free'
C:\wxsqlite3-3.0.3\lib\gcc_lib/libwxcode_msw29u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0x25e): undefined reference to `sqlite3_malloc'
C:\wxsqlite3-3.0.3\lib\gcc_lib/libwxcode_msw29u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0x29e): undefined reference to `sqlite3_malloc'
...
I simply add a piece of code from the wxsqlite3 example as well as the #include to the codeblock generated wxwidgets example application

Code: Select all

wxSQLite3Database* db = new wxSQLite3Database();
Besides, I have both sqlite3 and wxsqlite3 in the search directory for both compiler and linker, and I have read this post http://forums.wxwidgets.org/viewtopic.php?f=30&t=30521, but it does not help. Here is the linked lib order:
Image

The strange thing is, using similar settings and code with vc10 compiler, it can finish the compile and generate exe file. And both compiler (tdm-gcc and vc10 both 64bit) can compile and link the wxsqlite3 lib with its sample and the sample gives same output, I believe.

Any one can help?

Thank you.
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxSQLite3 compile problem

Post by utelle »

de wrote:

Code: Select all

...
g++.exe -LC:\sqlite-amalgamation-3071602 -LC:\wxWidgets-2.9.4\lib\gcc_lib -LC:\wxsqlite3-3.0.3\lib\gcc_lib -LC:\wxWidgets-2.9.4\lib\gcc_lib  -o "bin\Release gcc\prototype.exe" "obj\Release gcc\prototypeApp.o" "obj\Release gcc\prototypeMain.o"  "obj\Release gcc\resource.res"  -mthreads  -lsqlite3 -lwxmsw29u_core -lwxbase29u -lwxpng -lwxjpeg -lwxtiff -lwxzlib -lwxregexu -lwxcode_msw29u_wxsqlite3 -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32  -mwindows
C:\wxsqlite3-3.0.3\lib\gcc_lib/libwxcode_msw29u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0x167): undefined reference to `sqlite3_result_text'
C:\wxsqlite3-3.0.3\lib\gcc_lib/libwxcode_msw29u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0x185): undefined reference to `sqlite3_free'
C:\wxsqlite3-3.0.3\lib\gcc_lib/libwxcode_msw29u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0x195): undefined reference to `sqlite3_free'
C:\wxsqlite3-3.0.3\lib\gcc_lib/libwxcode_msw29u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0x205): undefined reference to `sqlite3_free'
C:\wxsqlite3-3.0.3\lib\gcc_lib/libwxcode_msw29u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0x215): undefined reference to `sqlite3_free'
C:\wxsqlite3-3.0.3\lib\gcc_lib/libwxcode_msw29u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0x25e): undefined reference to `sqlite3_malloc'
C:\wxsqlite3-3.0.3\lib\gcc_lib/libwxcode_msw29u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0x29e): undefined reference to `sqlite3_malloc'
...
Obviously the linker doesn't resolve the dependencies on the SQLite library ...
de wrote: Besides, I have both sqlite3 and wxsqlite3 in the search directory for both compiler and linker, and I have read this post http://forums.wxwidgets.org/viewtopic.php?f=30&t=30521, but it does not help. Here is the linked lib order:
Image
... and from the shown link order it gets clear why:

wxSQLite3 depends on SQLite - therefore the wxSQLite3 library has to be placed before the SQLite library, because otherwise the GCC linker won't be able to resolve the unresolved symbols from wxSQLite3. The VC++ linker works differently: it always searches all given link libraries, and is therefore less dependent on the order of the link libraries.

Moving libwxcode_msw29u_wxsqlite3.a to the top of the list should solve the linker issue.

Regards,

Ulrich
de
In need of some credit
In need of some credit
Posts: 2
Joined: Sun May 19, 2013 8:52 pm

Re: wxSQLite3 compile problem

Post by de »

Thank you Ulrich, your are definitely right. This solved my problem.
Post Reply