User forums > Help

How to build wxwidgets-2.6.3 to work with code::blocks

<< < (4/6) > >>

thomas:
Here comes the wxWidgets hater. :)
Ok, everybody who has read more than 3 threads on this forum knows my opinion on wxWidgets, but seriously: here is a little of my experience. :)

One important thing with wxWidgets is that you have to build it monolithic (either static or shared, doesn't matter), or your life will be a very unhappy one.
In fact, a monolithic shared build works very nicely out of the box if you can live with distributing a huge dll. If only this dll wasn't so massively fat.

Don't tune any of the configuration options that are readily available because wxWidgets is not really meant to be tuned.
For example, many options that say "can safely be turned off if you don't need it" cause either your wxWidgets build to fail after running 75% OK, or they cause missing symbols when you try to link your program (no error earlier).

Similar strange things happen with non-monolithic builds. In theory, you should be able to leave out a few libraries if you don't use most features, but in practice, it only works if you include almost all or all of them, even for the most basic applications.
Also, I had it happen that the same program linked with a non-monolithic build crashed, but it would work fine with a monolithic build (identical options, except for this one flag).

wxWidgets requires you to link to a ton of other libraries. If you get a thousand errors when building your programs, you should try adding libkernel32.a, libuser32.a, libgdi32.a, libcomdlg32.a, libuuid.a, libole32.a,  liboleaut32.a, libvomctl32.a, libshell32.a, libadvapi32.a.
If you still get missing symbols after that, you may have to add libwinmm.a, libwisock32.a and libwinspool.a too. Unluckily, the project wizard doesn't do that for you.

Last week, I wanted to make a simple statically linked application that did nothing but display a tray icon and two really simple dialogs. Since I did not know the Windows API for displaying tray icons, I made the massive mistake to give wxWidgets a try (as there is a ready-made tray icon class). Bad mistake!
After recompiling wxWidgets in several configurations several times and fighting for four hours to finally get a working 2 MB stripped executable, I decided to use raw Win32 API instead. It took little over one hour including reading the MSDN documentation, and the executable is 17 kB, including icons...

Regarding the project wizard, when I last used it a week ago, it made me cry because it was setting up everything incorrectly (did not specify the correct include and linker paths, and did not configure properly for static linkage either).
However, as Yiannis said above, the wizard has seen an overhaul, so that problem should be solved now. You still may have to add a few libraries by hand, but it should work rather painlessly now.

wittend:

--- Quote ---I have given a try to the wxWidgets template (Windows XP SP2, rev2689 built with GCC 3.4.5, wxWidgets 2.6.3 Patch 2 built with GCC 4.0.3, GCC 3.4.5) and it works fine. It builds without errors and warning and runs fine.

May be the problems you have are not with C::B or the template, but e.g., with your wxWidgets or others.

Patch 2 for wxWidgets 2.6.3 can be found here.

--- End quote ---

I rebuilt wxWidgets and upgraded the IDE before running this build.  The only thing that I have not yet done is create another app de novo.

-- Dave

wittend:

--- Quote from: Ceniza on July 05, 2006, 09:36:03 pm ---Could you check if you have in the list of defines for your project WXUSINGDLL?

If it's not there add it and rebuild your project.

--- End quote ---

That helped.  I remember explicitly removing WXUSINGDLL because elswhere I had attempted to specify a static build.   

After making this change, the output I recieve is this:

-------------- Build: default in test ---------------
mingw32-g++.exe -pipe -mthreads -Winvalid-pch -include "wx_pch.h" -D__GNUWIN32__ -D__WXMSW__ -DUSE_PCH -D__GNUWIN32__ -D__WXMSW__ -DUSE_PCH -DHAVE_W32API_H -DwxUSE_UNICODE -DwxUSE_THREADS -DWXUSINGDLL  -ID:\bin\wxWidgets-2.6.3\include -ID:\bin\wxWidgets-2.6.3\lib\gcc_dll\msw -ID:\bin\wxWidgets-2.6.3\contrib\include -ID:\bin\CodeBlocks\include -ID:\bin\wxWidgets-2.6.3\include -ID:\bin\wxWidgets-2.6.3\include\wx -ID:\bin\wxWidgets-2.6.3\lib\gcc_dll\mswu  -c wx_pch.h -o wx_pch.h.gch\default_wx_pch.h.gch
mingw32-g++.exe -pipe -mthreads -Winvalid-pch -include "wx_pch.h" -D__GNUWIN32__ -D__WXMSW__ -DUSE_PCH -D__GNUWIN32__ -D__WXMSW__ -DUSE_PCH -DHAVE_W32API_H -DwxUSE_UNICODE -DwxUSE_THREADS -DWXUSINGDLL  -ID:\bin\wxWidgets-2.6.3\include -ID:\bin\wxWidgets-2.6.3\lib\gcc_dll\msw -ID:\bin\wxWidgets-2.6.3\contrib\include -ID:\bin\CodeBlocks\include -ID:\bin\wxWidgets-2.6.3\include -ID:\bin\wxWidgets-2.6.3\include\wx -ID:\bin\wxWidgets-2.6.3\lib\gcc_dll\mswu  -c main.cpp -o .objs\main.o
mingw32-g++.exe -LD:\bin\wxWidgets-2.6.3\lib\gcc_dll -LD:\bin\wxWidgets-2.6.3\lib -LD:\bin\CodeBlocks\lib -LD:\bin\wxWidgets-2.6.3\lib  -o TEST.exe .objs\main.o    D:\bin\wxWidgets-2.6.3\lib\libwx_mswu-2.6.dll.a  -mwindows
.objs\main.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x138): undefined reference to `wxWindow::RegisterHotKey(int, int, int)'
.objs\main.o:main.cpp:(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x13c): undefined reference to `wxWindow::UnregisterHotKey(int)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 8 seconds)
0 errors, 0 warnings

I believe that I may be down to only the Hotkey errors.  I quess that those calls relate to the the default menu items in the minimal application.  If only I knew how to get rid of them.

-- Dave

wittend:
Aha! I built a new minimalist app with the new Wizard, and it worked! 

Thanks to everyone who read my posts and offered their suggestions!

-- Dave

Michael:

--- Quote from: thomas on July 06, 2006, 12:02:18 am ---Here comes the wxWidgets hater. :)
Ok, everybody who has read more than 3 threads on this forum knows my opinion on wxWidgets, but seriously: here is a little of my experience. :)

--- End quote ---

Hello,

Thank you very much for this very interesting post :).

Best wishes,
Michael

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version