0

I saw a lot of posts about this but no one helped me... My problem is that I want to use the static build so I can execute the compiled exe of my project without other files...

I compiled wxWidgets with the following commands:

mingw32-make -f makefile.gcc -j4 SHARED=0 MONOLITHIC=1 UNICODE=1 BUILD=release clean
mingw32-make -f makefile.gcc -j4 SHARED=0 MONOLITHIC=1 UNICODE=1 BUILD=release

But when I am using the build in CodeBlocks I get a lot of undefined reference errors

Link with the full list of errors: http://pastebin.com/2Ccs9nDu

In Codeblocks its using the following commands to compile:

mingw32-g++.exe -LD:\wxWidgets-3.0.2\lib\gcc_lib -o bin\Release\Test.exe obj\Release\TestApp.o obj\Release\Test.o obj\Release\resource.res -s -mthreads  -lwxmsw30u -lwxpng -lwxjpeg -lwxtiff -lwxzlib -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -mwindows

And these are the liked libarys:

        <Add option="-mthreads" />
        <Add library="libkernel32.a" />
        <Add library="libuser32.a" />
        <Add library="libgdi32.a" />
        <Add library="libwinspool.a" />
        <Add library="libcomdlg32.a" />
        <Add library="libadvapi32.a" />
        <Add library="libshell32.a" />
        <Add library="libole32.a" />
        <Add library="liboleaut32.a" />
        <Add library="libuuid.a" />
        <Add library="libcomctl32.a" />
        <Add library="libwsock32.a" />
        <Add library="libodbc32.a" />

Can anybody Help me? I red so much about it but I still dont know how I can fix this problem in Codeblocks. And sorry if I missed some important part.. I sadly dont know a lot about this topic because I just startet to use it.

PS: The non-static build works for me, only the static makes trouble...

PPS: I dont think it was a duplication of the post... I dont get the soloution out of the linked page... Please open this post again..

edit: here are the linker for the wxWidgets libaries:

            <Linker>
                <Add option="-s" />
                <Add library="libwxmsw30u.a" />
                <Add library="libwxpng.a" />
                <Add library="libwxjpeg.a" />
                <Add library="libwxtiff.a" />
                <Add library="libwxzlib.a" />
                <Add directory="D:/Project/wxWidgets-3.0.2/lib/gcc_lib" />
            </Linker>

Edit: This is how Code::Blocks compiles my Project

mingw32-g++.exe -LD:\Project\wxWidgets-3.0.2\lib\gcc_lib -o bin\Release\static_Test.exe  
obj\Release\static_TestApp.o obj\Release\static_TestMain.o obj\Release\resource.res 
-s -mthreads  -lwxmsw30u_core -lwxbase30u -lwxpng -lwxzlib -lkernel32 -luser32 
-lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 
-lwsock32 -lodbc32 -mwindows
Marius
  • 33
  • 1
  • 6

2 Answers2

0

You need to tell the linker to search for the static library in the folder where it was built - something like ...\wxWidgets-3.0.1\gcc_static_lib.

So change

mingw32-g++.exe -LD:\wxWidgets-3.0.2\wx\lib\gcc_lib

to

mingw32-g++.exe -LD:\wxWidgets-3.0.2\wx\gcc_static_lib

The easiest way to do that is to set a global variable. Do you know how to use this code::blocks feature?

enter image description here

enter image description here

ravenspoint
  • 19,093
  • 6
  • 57
  • 103
  • The problem is, I didnt even have the Static option ob my Project build options... I only have the release.? – Marius Jun 12 '15 at 14:30
  • Sorry, I forgot the wxWidgets libaries in my post. I added them at the end. They should be linked already.. – Marius Jun 12 '15 at 14:34
  • and I only have two folder under wxWidgets-3.0.2\wx\lib and this is "gcc_lib" and "watcom". The "gcc_lib" should be the static one.. I dont have another lib in there.. – Marius Jun 12 '15 at 14:36
  • In that case, something has gone wrong with your build of the static library. – ravenspoint Jun 12 '15 at 14:37
  • Yes but what? I tried it now like 5-10times... Do you know if "SHARED=0 MONOLITIC=1 BUILD=release" is the right flags to build a static release build? – Marius Jun 12 '15 at 14:39
  • Ok i probably got it.. I found this: "SHARED=0 RUNTIME_LIBS=static MONOLITHIC=1 BUILD=release" I will try to use this for building it... – Marius Jun 12 '15 at 14:41
  • Ok its still doesnt working.. -.- I get the some errors as before.. but its strange... the libary should be named something with static in it doesnt it? – Marius Jun 12 '15 at 15:03
  • Do you now have a folder ..\wxWidgets-3.0.2\gcc_static_lib? – ravenspoint Jun 12 '15 at 15:06
  • No... I just have again this: \wxWidgets-3.0.2\lib\gcc_lib ... I dont get it.. what do I do wrong?... – Marius Jun 12 '15 at 15:14
  • The problem cant be, that I created the Project of the Type "wxWidgets project" can it? – Marius Jun 12 '15 at 15:15
  • Are you following the recipe at http://wiki.codeblocks.org/index.php?title=Compiling_wxWidgets_3.0.0_to_develop_Code::Blocks_(MSW)? – ravenspoint Jun 12 '15 at 15:17
  • I saw this, but the problem is, they didnt build it static... Plus they using OpenGL support, which I dont need and USE_XRC=1 should be useless because they include this libary anyways... – Marius Jun 12 '15 at 15:45
0
g++ `wx-config --cxxflags` -I/usr/lib/x86_64-linux-gnu/wx/include/gtk2-unicode-3.0/ -I/usr/include/wx-3.0 -D_File_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -Wall -g -c mycode.cpp  -o mycode.o `wx-config --libs`

use this console command in linux to compile your code change mycode.cpp to your main file and mycode.o to output file for windows its a little bit different and longer, code::blocks will show you alternative command for windows if you compile sample project in it.

Mahdi Khalili
  • 1,025
  • 15
  • 32