Do you have -s option for stripping enabled?
Yes, oBFusCATed, compiler options in C::B indicates "-s" (strip all symbols) and "-O2" (optimize for speed)
Are you sure both libs are compiled in release mode by the same compiler?
Yes, both have been compiled with same version of TDM-GCC (the tdm-gcc-4.6.1.exe package) using this command line :
mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=0 UNICODE=1 BUILD=release CXXFLAGS="-fno-keep-inline-dllexport"
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.
WXWIN_COMPATIBILITY_2_8 0
#ifdef NDEBUG
#define wxDEBUG_LEVEL 0
#else
#define wxDEBUG_LEVEL 2
#endif
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 :
libwxmsw29u.a (static LIB) is now 41 530 KB (was 45 958) : so, a very little difference (- 7%)
Also, I've rebuilt the minimal Code::Blocks project :
executable (release) is now 5.65 MB (was 7.07 MB) : so, a valuable difference (- 20%), but still a big exe
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.
Yes, ptDev : even if nothing done towards wx-dev mailing list (I've subscribed to user side, but not dev one yet), I've already opened a thread about this in the wxWidgets forum. It's here : http://forums.wxwidgets.org/viewtopic.php?f=1&t=35103&p=143804
Thanks for these added info, xunxun ; until now, I've pushed a little bit further (see my results below), but wouldn't fall in a too specific optimization ; knowing same wx libs should work for several projects, and it's difficult to remember to not use this or that... Well, here are my results until now (and a problem too) :
--
So, as said above, I've tried to reduce the exe size a little bit more like this :
- Rebuild wxWidgets 2.9.3 w/ "WXWIN_COMPATIBILITY_2_8 0" & "wxDEBUG_LEVEL 0" in setup.h => my mini_wx29_project's exe becomes 5.65 MB
- Post-build w/ "strip --strip-all XXX.exe" (read it's sometime better than GCC -Os) : negligible, but I keep-it (- 0.01 MB)
- Rebuild wxWidgets 2.9.3 adding theses make options : CFLAGS='-Os -fdata-sections -ffunction-sections' CXXFLAGS='-Os -fdata-sections -ffunction-sections -fno-keep-inline-dllexport' LDFLAGS='-Wl,--gc-sections' => mini_wx29_project is now 3.64 MB, but w/ a lot of warnings about sections.
Thus, now my initial minimalist project of 7.07 MB is 3.64 MB, but linker returns a lot of warnings (about 300 lines like the ones below) :
Linking executable: bin\Release\wx29_cb-mini.exe
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\devlibs\wxWidgets\lib\gcc_lib/libwxmsw29u.a(monolib_gdicmn.o): warning: duplicate section `.rdata$_ZTV20wxThreadHelperThread[vtable for wxThreadHelperThread]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\devlibs\wxWidgets\lib\gcc_lib/libwxmsw29u.a(monolib_window.o): warning: duplicate section `.rdata$_ZTV20wxThreadHelperThread[vtable for wxThreadHelperThread]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\devlibs\wxWidgets\lib\gcc_lib/libwxmsw29u.a(monolib_window.o): warning: duplicate section `.rdata$_ZTV13wxTransform2D[vtable for wxTransform2D]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\devlibs\wxWidgets\lib\gcc_lib/libwxmsw29u.a(monolib_mdi.o): warning: duplicate section `.rdata$_ZTV20wxThreadHelperThread[vtable for wxThreadHelperThread]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\devlibs\wxWidgets\lib\gcc_lib/libwxmsw29u.a(monolib_mdi.o): warning: duplicate section `.rdata$_ZTV21wxMDIClientWindowBase[vtable for wxMDIClientWindowBase]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\devlibs\wxWidgets\lib\gcc_lib/libwxmsw29u.a(monolib_mdi.o): warning: duplicate section `.rdata$_ZTS19wxNavigationEnabledI16wxNonOwnedWindowE[typeinfo name for wxNavigationEnabled<wxNonOwnedWindow>]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\devlibs\wxWidgets\lib\gcc_lib/libwxmsw29u.a(monolib_appbase.o): warning: duplicate section `.rdata$_ZTV20wxThreadHelperThread[vtable for wxThreadHelperThread]' has different size
[...]
Output size is 3.64 MB
Running target post-build steps
strip --strip-all wx29_cb-mini.exe
Process terminated with status 0 (0 minutes, 28 seconds)
0 errors, 305 warnings (0 minutes, 28 seconds)
Do you have an idea to avoid these hundreds of warnings ?
I've asked in the wxWidgets forum too (see URL I indicate at top of this post).
Next step could be to use no-monolithic linking, but, before, I would like to remove theses warnings ::)
--
EDIT : I try to advance. Now, I've got only 6 warnings (rather than hunderds) but two errors too (so, it doesn't build)
Here are the options I've indicated :
For compiler :
-ffunction-sections
-fdata-sections
-Wl,-allow-multiple-definition
-flto
For linker :
-flto
-Os
-Wl,--gc-sections
-Wl,-allow-multiple-definition
And I get this :
Compiling: resource.rc
Compiling: wx29_cb_miniMain.cpp
Linking executable: bin\Release\wx29_cb-mini.exe
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\DOCUME~1\eln\LOCALS~1\Temp\cctYhhpd.ltrans0.ltrans.o: warning: duplicate section `.rdata$_ZTS19wxNavigationEnabledI16wxNonOwnedWindowE[typeinfo name for wxNavigationEnabled<wxNonOwnedWindow>]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\DOCUME~1\eln\LOCALS~1\Temp\cctYhhpd.ltrans0.ltrans.o: warning: duplicate section `.rdata$_ZTV13wxTransform2D[vtable for wxTransform2D]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\DOCUME~1\eln\LOCALS~1\Temp\cctYhhpd.ltrans0.ltrans.o: warning: duplicate section `.rdata$_ZTV20wxThreadHelperThread[vtable for wxThreadHelperThread]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\DOCUME~1\eln\LOCALS~1\Temp\cctYhhpd.ltrans1.ltrans.o: warning: duplicate section `.rdata$_ZTS19wxNavigationEnabledI16wxNonOwnedWindowE[typeinfo name for wxNavigationEnabled<wxNonOwnedWindow>]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\DOCUME~1\eln\LOCALS~1\Temp\cctYhhpd.ltrans1.ltrans.o: warning: duplicate section `.rdata$_ZTS19wxNavigationEnabledI8wxWindowE[typeinfo name for wxNavigationEnabled<wxWindow>]' has different size
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: C:\DOCUME~1\eln\LOCALS~1\Temp\cctYhhpd.ltrans1.ltrans.o: warning: duplicate section `.rdata$_ZTS17wxWindowWithItemsI9wxControl15wxItemContainerE[typeinfo name for wxWindowWithItems<wxControl, wxItemContainer>]' has different size
C:\DOCUME~1\eln\LOCALS~1\Temp\cctYhhpd.ltrans0.ltrans.o:cctYhhpd.ltrans0.o:(.text+0xd22): undefined reference to `wxTheAssertHandler'
C:\DOCUME~1\eln\LOCALS~1\Temp\cctYhhpd.ltrans0.ltrans.o:cctYhhpd.ltrans0.o:(.text+0xd51): undefined reference to `wxOnAssert(char const*, int, char const*, char const*, wchar_t const*)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 39 seconds)
2 errors, 6 warnings (0 minutes, 39 seconds)
Knowing I've maybe made obvious mistake with theses options : I'm new in GCC as in C::B and wxWidgets :o Do you have an idea, an advice ?
No, effectively, Alpha, you're right... But, here is progress
About wxWidgets 2.9.3
- I've changed setup.h with "WXWIN_COMPATIBILITY_2_8 0" and "wxDEBUG_LEVEL 0"
- I've cleaned with "mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=0 UNICODE=1 BUILD=release clean"
- Then built with :
mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=0 UNICODE=1 BUILD=release CFLAGS="-Os -fdata-sections -ffunction-sections" CXXFLAGS="-Os -fdata-sections -ffunction-sections -fno-keep-inline-dllexport" LDFLAGS="-Wl,--gc-sections"
About the test project
Initially, default Code::Blocks project settings gave me 305 warnings and 0 error :
GCC with "-Wall -s -O2 -pipe -mthreads -Wno-attributes -include wx_pch.h -Winvalid-pch", and linker with "-mthreads"
And the same (305 warnings and 0 error) if I just add the same options as the ones provided during wxWidget building :
"GCC with default setting above + "-fdata-sections -ffunction-sections -fno-keep-inline-dllexport"
Linker with default setting above + "-Wl,--gc-sections"
Then, I've tried to remove these warnings using differents options (but, effectivelly, w/o rebuild of wxWidgets itself)... After some hours, I've got this combination which gave me 2 errors and 6 warnings :
GCC with default setting above + "-Os -ffunction-sections -fdata-sections -Wl,-allow-multiple-definition -flto"
Linker with default setting above + "-flto -Os -Wl,--gc-sections"-Wl,-allow-multiple-definition"
So, what should I do from this point : remove options in my test project or add ones in a new wxWidgets rebuild ?
PS : also, in parallel, maybe I'l take a try w/ MSVC compiler... But it would be great to obtains something acceptable with GCC.
--
EDIT : knowing, of course, after every change in build options, I do a complete rebuild (with clean ahead)