Code::Blocks Forums

User forums => Help => Topic started by: siegfried on September 08, 2008, 08:10:16 pm

Title: Static linking problem - wxWidgets
Post by: siegfried on September 08, 2008, 08:10:16 pm
Hello everyone.
I think this topic is like a boomerang - it always comes back :( sorry for this but I spent all day and I am going nuts. I've read a lot of posts on forum.
I am using Code:Blocks SVN 4893, windows Vista, mingw 5.1.4, gcc

ok, I have wxWidgets 2.8.8, build like:

mingw32-make -f makefile.gcc USE_XRC=1 MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=debug USE_OPENGL=1
mingw32-make -f makefile.gcc USE_XRC=1 MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release USE_OPENGL=1
mingw32-make -f makefile.gcc USE_XRC=1 MONOLITHIC=1 SHARED=0 UNICODE=1 BUILD=debug USE_OPENGL=1
mingw32-make -f makefile.gcc USE_XRC=1 MONOLITHIC=1 SHARED=0 UNICODE=1 BUILD=release USE_OPENGL=1

so in theory I have static libraries + dll version. DLL applications compile & link like a charm. If I create new test project and disable "DLL linking" (or something like this), it works. But the main project doesnt link at all.


I changed global compiler settings to:
$linker -o $exe_output $libdirs $link_objects $link_resobjects $libs $link_options  -mwindows

my linker settings:
Code
libwxmsw28u_gl.a (I tried almost everything here)
libwxpng.a
libwxjpeg.a
libwxtiff.a
libwxzlib.a

search dirs (compiler, linker, resource):
Code
C:\wxWidgets-2.8.8\lib\gcc_lib\mswu
C:\wxWidgets-2.8.8\lib\gcc_lib
C:\wxWidgets-2.8.8\lib\gcc_lib\mswu

still what I get is:
Code
obj\Release_static\dungeon_editorApp.o:dungeon_editorApp.cpp:(.text+0x49)||undefined reference to `_imp___ZN12wxAppConsole17CheckBuildOptionsEPKcS1_'|
obj\Release_static\dungeon_editorApp.o:dungeon_editorApp.cpp:(.text+0x6c)||undefined reference to `_imp___ZN5wxAppC2Ev'|
obj\Release_static\dungeon_editorApp.o:dungeon_editorApp.cpp:(.text+0xd2)||undefined reference to `_imp___ZN12wxAppConsole14ms_appInstanceE'|
obj\Release_static\dungeon_editorApp.o:dungeon_editorApp.cpp:(.text+0x103)||undefined reference to `_imp___Z7wxEntryP11HINSTANCE__S0_Pci'|
obj\Release_static\dungeon_editorApp.o:dungeon_editorApp.cpp:(.text+0x157)||undefined reference to `_imp___Z22wxInitAllImageHandlersv'|
obj\Release_static\dungeon_editorApp.o:dungeon_editorApp.cpp:(.text+0x202)||undefined reference to `_imp___ZN12wxAppConsole12ms_appInitFnE'|

(and so on....) A LOT!

PLEASE HELP!  :shock:


Title: Re: Static linking problem - wxWidgets
Post by: stahta01 on September 08, 2008, 08:50:47 pm
Are you linking to libwxmsw28u.a ?

Turn on Compiler Logging and post the link command.
http://wiki.codeblocks.org/index.php?title=FAQ&Itemid=5#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

Tim S

My guess of libraries to link; I don't use wxWidgets Static Monolithic build
Code
libwxmsw28u_gl.a
libwxmsw28u.a
libwxpng.a
libwxjpeg.a
libwxtiff.a
libwxzlib.a
Title: Re: Static linking problem - wxWidgets
Post by: siegfried on September 08, 2008, 09:04:26 pm
Code
mingw32-g++.exe -o bin\Release_static\dungeon_editor.exe -LC:\wxWidgets-2.8.8\lib\gcc_lib -LC:\wxWidgets-2.8.8\lib\gcc_lib 
-LC:\MinGW\lib  obj\Release_static\dungeon_editorApp.o obj\Release_static\dungeon_editorMain.o obj\Release_static\mapTile.o
obj\Release_static\NewSetDialog.o  obj\Release_static\resource.res  -lwxmsw28u_gl -lwxpng -lwxjpeg -lwxtiff -lwxzlib -lkernel32
-luser32 -lgdi32  -s   -mwindows
I checked with -lwxmsw28u as well. still nothing  :?
Title: Re: Static linking problem - wxWidgets
Post by: stahta01 on September 08, 2008, 09:11:07 pm
Try it again with lib wxmsw28u again and post both the compiler and link commands.
And, the error messages

Tim S
Title: Re: Static linking problem - wxWidgets
Post by: siegfried on September 08, 2008, 09:20:22 pm
Code
mingw32-g++.exe -O2  -Wall -pipe -mthreads  -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE    
-IC:\wxWidgets-2.8.8\lib\gcc_lib\mswu -IC:\wxWidgets-2.8.8\include
-IC:\wxWidgets-2.8.8\contrib\include -IC:\wxWidgets-2.8.8\lib\gcc_dll\mswu -IC:\glut-3.7.6-bin
-IC:\wxWidgets-2.8.8\lib\gcc_lib\mswu  -c "C:\C projects\dungeon_editor\mapTile.cpp"
-o obj\Release_static\mapTile.o

windres.exe -i C:\CPROJE~1\DUNGEO~2\resource.rc -J rc -o obj\Release_static\resource.res -O coff
-IC:\wxWidgets-2.8.8\lib\gcc_lib\mswu -IC:\wxWidgets-2.8.8\include -IC:\MinGW\include

mingw32-g++.exe -O2  -Wall -pipe -mthreads  -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE   
-IC:\wxWidgets-2.8.8\lib\gcc_lib\mswu -IC:\wxWidgets-2.8.8\include -IC:\wxWidgets-2.8.8\contrib\include
-IC:\wxWidgets-2.8.8\lib\gcc_dll\mswu -IC:\glut-3.7.6-bin -IC:\wxWidgets-2.8.8\lib\gcc_lib\mswu 
-c "C:\C projects\dungeon_editor\NewSetDialog.cpp" -o obj\Release_static\NewSetDialog.o

mingw32-g++.exe -o bin\Release_static\dungeon_editor.exe -LC:\wxWidgets-2.8.8\lib\gcc_lib -LC:\wxWidgets-2.8.8\lib\gcc_lib
-LC:\MinGW\lib  obj\Release_static\dungeon_editorApp.o obj\Release_static\dungeon_editorMain.o obj\Release_static\mapTile.o
obj\Release_static\NewSetDialog.o  obj\Release_static\resource.res  -lwxmsw28u -lwxmsw28u_gl -lwxpng -lwxjpeg -lwxtiff
-lwxzlib  -s   -mwindows



Title: Re: Static linking problem - wxWidgets
Post by: stahta01 on September 08, 2008, 09:29:17 pm
Did you try the -lwxmsw28u after -lwxmsw28u_gl because order of libraries matter?

I am guessing wxmsw28u should be after wxmsw28u_gl.

Did the error go away? Did it change?

WARNING: You must not mix DLL and Static search folders for the same libraries
-IC:\wxWidgets-2.8.8\lib\gcc_dll\mswu


The search -IC:\wxWidgets-2.8.8\lib\gcc_dll\mswu will result in the wrong setup.h being found which can cause all sorts of errors.

FYI: IMO, The linker errors you are getting is caused by wxmsw28u not being in the right spot in the library list.

Tim S
Title: Re: Static linking problem - wxWidgets
Post by: siegfried on September 08, 2008, 09:39:34 pm
ok,so now we have:
Code
mingw32-g++.exe -O2   -Wall -pipe -mthreads  -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE    
-IC:\wxWidgets-2.8.8\lib\gcc_lib\mswu -IC:\wxWidgets-2.8.8\include -IC:\wxWidgets-2.8.8\contrib\include
-IC:\wxWidgets-2.8.8\lib\gcc_lib\mswu -IC:\glut-3.7.6-bin  -c "C:\C projects\dungeon_editor\dungeon_editorApp.cpp"
-o obj\Release_static\dungeon_editorApp.o
mingw32-g++.exe -O2   -Wall -pipe -mthreads  -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE   
-IC:\wxWidgets-2.8.8\lib\gcc_lib\mswu -IC:\wxWidgets-2.8.8\include -IC:\wxWidgets-2.8.8\contrib\include
-IC:\wxWidgets-2.8.8\lib\gcc_lib\mswu -IC:\glut-3.7.6-bin  -c "C:\C projects\dungeon_editor\dungeon_editorMain.cpp"
-o obj\Release_static\dungeon_editorMain.o

mingw32-g++.exe -O2   -Wall -pipe -mthreads  -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE   
-IC:\wxWidgets-2.8.8\lib\gcc_lib\mswu -IC:\wxWidgets-2.8.8\include -IC:\wxWidgets-2.8.8\contrib\include
-IC:\wxWidgets-2.8.8\lib\gcc_lib\mswu -IC:\glut-3.7.6-bin  -c "C:\C projects\dungeon_editor\mapTile.cpp"
-o obj\Release_static\mapTile.o
windres.exe -i C:\CPROJE~1\DUNGEO~2\resource.rc -J rc -o obj\Release_static\resource.res -O coff
-IC:\wxWidgets-2.8.8\lib\gcc_lib\mswu -IC:\wxWidgets-2.8.8\include -IC:\MinGW\include
mingw32-g++.exe -O2   -Wall -pipe -mthreads  -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE   
-IC:\wxWidgets-2.8.8\lib\gcc_lib\mswu -IC:\wxWidgets-2.8.8\include -IC:\wxWidgets-2.8.8\contrib\include
-IC:\wxWidgets-2.8.8\lib\gcc_lib\mswu -IC:\glut-3.7.6-bin  -c "C:\C projects\dungeon_editor\NewSetDialog.cpp"
-o obj\Release_static\NewSetDialog.o
mingw32-g++.exe -o bin\Release_static\dungeon_editor.exe -LC:\wxWidgets-2.8.8\lib\gcc_lib
-LC:\wxWidgets-2.8.8\lib\gcc_lib -LC:\MinGW\lib  obj\Release_static\dungeon_editorApp.o
obj\Release_static\dungeon_editorMain.o obj\Release_static\mapTile.o obj\Release_static\NewSetDialog.o 
obj\Release_static\resource.res  -lwxmsw28u_gl -lwxmsw28u -lwxpng -lwxjpeg -lwxtiff -lwxzlib  -s   -mwindows


I changed order of libraries and I kicked out the DLL search path. By the way: I thought wxms28u and wxms28u_gl are the same- second is with gl enabled - but obviously I was wrong: one is 18mb, second 800 bytes ;)

ONE SECOND!
Now I am getting different set of linking errors - obviously wx errors are gone and now it's standard set of ole etc.

I think you are Programming God, Tim ;)
Title: Re: Static linking problem - wxWidgets
Post by: stahta01 on September 08, 2008, 09:45:31 pm
I am off to college class; wish you look on the new errors.

Tim S
Title: Re: Static linking problem - wxWidgets
Post by: siegfried on September 08, 2008, 09:49:19 pm
ok it works now.
Thank you for you help, Tim.