User forums > General (but related to Code::Blocks)
Abnormal difference of exe size using C::B wizard against wxWidgets 2.9 ?!
eranon:
Hello,
Upgrading from wxWidgets 2.8.12 to wxWidgets 2.9.3, I was very surprise to see my exe increased dramatically. So, I've asked in the wxWidgets (here :) and it sounds like this is quite bigger than what I could expect (for example, doublemax on wxWidgets forum tell me he got a 1MB difference only in a minimal project).
So, I've done some tests using Code::Blocks Wizard. I've created two minimal projects with same wizard options (ie. GUI w/frame, using wxSmith, linking to unicode monolithic static wxWidgets). Here are the results for release builds :
- Project using wxWidgets 2.8 is 2.44 MB :)
- Project using wxWidgets 2.9 is 7.07 MB :(
Also, knowing I'm with Code::Blocks under Windows using TDM-GCC compiler.
So, what to do to get an acceptable size w/ wxWidgets 2.9 ? Is it related to something forced by C::B wizard about GCC compiler ? A little bit worried ::)
oBFusCATed:
Do you have -s option for stripping enabled?
Are you sure both libs are compiled in release mode by the same compiler?
eranon:
--- Quote from: oBFusCATed on May 27, 2012, 10:30:03 pm ---Do you have -s option for stripping enabled?
--- End quote ---
Yes, oBFusCATed, compiler options in C::B indicates "-s" (strip all symbols) and "-O2" (optimize for speed)
--- Quote from: oBFusCATed on May 27, 2012, 10:30:03 pm ---Are you sure both libs are compiled in release mode by the same compiler?
--- End quote ---
Yes, both have been compiled with same version of TDM-GCC (the tdm-gcc-4.6.1.exe package) using this command line :
--- Code: ---mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=0 UNICODE=1 BUILD=release CXXFLAGS="-fno-keep-inline-dllexport"
--- End code ---
ptDev:
The considerable difference in size between executables compiled with wx 2.8 and 2.9 is a widely known issue.
wxWidgets 2.9 generates bigger executables due to increased debug checks that included in the release build, an increased amount of class libraries and recently, in wx2.9.4, due to strings being UTF32 based by default (this carries with it the performance penalty due the repeated conversions back and forth between UTF32 and UTF8 as well - although ways to facilitate these needs are still being worked on).
The only sensible advice, besides using optimal compiler settings, is to edit the setup.h header, enforce wxDEBUG_LEVEL to 0 for release builds (which is not the case by default), judiciously disable every single option you will never use, and recompile wxWidgets. Removing wx 2.8 backwards compatibility will also reduce the API size, at the expense of forcing you to rewrite some parts of your applications.
EDIT: Also consider a non-monolithic build: you will only need to distribute the used DLLs with your application.
eranon:
OK, thanks for these lighted advice ptDev : I'll take a look to the 2.9's setup.h. Also, I've bookmarked this page, given to me by doublemax on the wxWidgets forum : http://wxwidgets.blogspot.de/2009/09/debug-build-changes-in-wx3.html (maybe there are some additional info over there).
About 2.8 compatibility : since I'm using wxWidgets recently, it could be manageable to rewrite some parts of code. So, could you indicate me the right page which talk about deprecated 2.8 features/classes/methods ?
About my use of static lib (no shared), it's just because I've to produce portable applis w/o possibility to check about presence of DLL at setup-time (since there's not any setup) ::)
--
EDIT : Combining your info, devPt, and the one from doublemax in wxWidgets forum, I've modified setup.h's like below and relaunched my wxWidgets 2.9 build session from a batch... I'll see tomorrow morning if it's better.
--- Code: ---WXWIN_COMPATIBILITY_2_8 0
#ifdef NDEBUG
#define wxDEBUG_LEVEL 0
#else
#define wxDEBUG_LEVEL 2
#endif
--- End code ---
Also, I've kept the two libwxmsw29u.a built with defaut setup.h
- libwxmsw29u.a for DLL was : 24 188 KB
- libwxmsw29u.a as LIB was : 45 958 KB
I'll tell you the new size tomorrow... Hoping [-o<
--
EDIT 2 : result after my re-compil of wxWidgets 2.9.3 removing backward compatibility to 2.8 and adding wxDEBUG_LEVEL 0 :
--- Code: ---libwxmsw29u.a (static LIB) is now 41 530 KB (was 45 958) : so, a very little difference (- 7%)
--- End code ---
Also, I've rebuilt the minimal Code::Blocks project :
--- Code: ---executable (release) is now 5.65 MB (was 7.07 MB) : so, a valuable difference (- 20%), but still a big exe
--- End code ---
I continue to search (using compilers option about size, looking at no-monolithic side and, maybe, others compilers)... However, if I don't succeed I'll have to return to the 2.8.
Navigation
[0] Message Index
[#] Next page
Go to full version