Hello,
I'm new to Code::Blocks and wxWidgets and was wondering if anyone knew of any good techniques for reducing the size of a "Hello World" application using wxWidgets and compiled by mingw. I followed the wiki page tutorial for compiling a Unicode, release build, monolithic DLL with mingw-make, but the final DLL was about 9MB! I got the sample program of Code::Blocks to compile and run correctly with the DLL, but I don't want the program size to be so large. (By the way, I believe there were two instances of C-strings that needed to be converted to Unicode strings with a macro in the sample source code outputted by C::B.)
I also built a Unicode, release build, non-monolithic library (not a DLL) and had success with getting that to work and link with the sample code using C::B and mingw, but the resulting .exe was about 5MB. I removed some extra libraries like opengl and obdc that I wasn't using, but that didn't help the size of the exe much.
With MS VC++ 6.0, I was able to compile the wxWidgets library (release + non Unicode + non DLL), and could link it into a "Hello World" application resulting in an .exe size of only 960KB. I only included the base and core wxWidget libraries and the typical Windows libraries. I would really like to use Code::Blocks instead, especially since it is open-source and contains wxSmith, but I just can't seem to be able to keep the size of the resulting application down.
I tried linking the library I built with MS VC++ 6.0 compiling with the mingw compiler of C::B, but I got a number of link errors. I tried doing that in hopes that I'd get the reduced size I could achieve with VC++. Here is some of the output:
Project : wxWidgets application
Compiler : GNU GCC Compiler (called directly)
Directory : E:\Documents and Settings\Marty\Desktop\xw-vslib-nounicode\
--------------------------------------------------------------------------------
Switching to target: default
Precompiling header: wx_pch.h
Compiling: main.cpp
Linking executable: E:\Documents and Settings\Marty\Desktop\xw-vslib-nounicode\wxWidgets.exe
.objs\main.o: In function `ZN8wxStringaSERKS_':
E:/wxWidgets-2.6.3/include/wx/window.h:(.text+0x4c): undefined reference to `wxAppConsole::CheckBuildOptions(char const*, char const*)'
.objs\main.o: In function `WinMain':
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:297: undefined reference to `wxEntry(HINSTANCE__*, HINSTANCE__*, char*, int)'
.objs\main.o: In function `ZN7MyFrameC2EP7wxFrameRK8wxString':
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:22: undefined reference to `wxFrameNameStr'
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:22: undefined reference to `wxDefaultSize'
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:22: undefined reference to `wxDefaultPosition'
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:23: undefined reference to `wxMenuBar::wxMenuBar()'
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:32: undefined reference to `wxFrameBase::SetMenuBar(wxMenuBar*)'
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:32: undefined reference to `wxFrame::~wxFrame()'
.objs\main.o: In function `ZN7MyFrameC1EP7wxFrameRK8wxString':
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:22: undefined reference to `wxFrameNameStr'
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:22: undefined reference to `wxDefaultSize'
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:22: undefined reference to `wxDefaultPosition'
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:23: undefined reference to `wxMenuBar::wxMenuBar()'
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:32: undefined reference to `wxFrameBase::SetMenuBar(wxMenuBar*)'
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:32: undefined reference to `wxFrame::~wxFrame()'
.objs\main.o: In function `ZN7MyFrameD2Ev':
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:36: undefined reference to `wxFrame::~wxFrame()'
.objs\main.o: In function `ZN7MyFrameD1Ev':
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:36: undefined reference to `wxFrame::~wxFrame()'
.objs\main.o: In function `ZN7MyFrameD0Ev':
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:36: undefined reference to `wxFrame::~wxFrame()'
.objs\main.o: In function `ZN7MyFrame6OnQuitER14wxCommandEvent':
E:/Documents and Settings/Marty/Desktop/xw-vslib-nounicode/main.cpp:41: undefined reference to `wxWindowBase::Close(bool)'
...
Did anyone ever manage to make a wxWidgets application with a file size that is less than 2MB? Also, does anyone know why the functions are not linking correctly when I use the MS VC++ 6.0 library? I am assuming that mingw's link program is not compatable with VC++ libraries.
Thanks! Btw, C::B looks really great and I hope to use it for all of my C++ applications from now on!