Author Topic: warnings when creating a GUI app based on wxWidgets  (Read 3746 times)

Offline fancyivan

  • Multiple posting newcomer
  • *
  • Posts: 11
warnings when creating a GUI app based on wxWidgets
« on: July 22, 2013, 11:37:38 am »
Hello,

1). Win7 x86, MinGW, wxWidgets2.9.x, Code::Blocks12.11

2) I compiled the Release version of wx2.9.4 by using the following script:
>>mingw32-make -f makefile.gcc CFLAGS=”-Os” CXXFLAGS=”-Os” DEBUG_FLAG=0 BUILD=release

I mean, I used "-Os" option when compiling wxWidgets. And also,  I found that the default option for release is "-O2"  in makefile.gcc:

ifeq ($(BUILD),release)
__OPTIMIZEFLAG_2 = -O2
endif

When compiling,  I found that the script is sth like:  g++ ****  -O2 -mthread ***** -Os ****. (first -O2, then -Os)

3) Then I tried to create a minimal GUI project(wxWidgets) in CodeBlocks. for Release version, I checked both "-O2" and "-Os".
I found that in file "project.cbp" is sth like this:
<Target title="Release">
  <Compiler>
    <Add option="-Os" />
    <Add option="-O2" />
    <Add option="-w" />
    <Add option="-DwxDEBUG_LEVEL=0" />
    <Add directory="$(#wx)/lib/gcc_lib/mswu" />
  </Compiler>
</Target>

when compile this project, the final script is:
mingw32-g++.exe -pipe -mthreads *****  -Os -O2  **** ** (first -Os, then -O2),

then I got many many warnings like:(may be I should not call them warnings, only some strange messages.)
==============================
C:\CodeBlocks\wxWidgets-2.9.5\lib\gcc_lib\libwxbase29u.a(baselib_wxprintf.o): duplicate section `.rdata$_ZTV20wxThreadHelperThread[vtable for wxThreadHelperThread]' has different size
C:\CodeBlocks\wxWidgets-2.9.5\lib\gcc_lib\libwxbase29u.a(baselib_mimetype.o): duplicate section `.rdata$_ZTV20wxThreadHelperThread[vtable for wxThreadHelperThread]' has different size
C:\CodeBlocks\wxWidgets-2.9.5\lib\gcc_lib\libwxbase29u.a(baselib_textfile.o): duplicate section `.rdata$_ZTV20wxThreadHelperThread[vtable for wxThreadHelperThread]' has different size
...........
0 errors, 0 warnings (0 minutes, 13 seconds)
==========================================

4) I found that If I change the order(first -O2 then -Os, the same order as compiling wxWidgets) in the final script, everything will be ok.

anyboby can say sth about this issue?   For now, I just removed the -O2, keeped -Os option for GUI project.

Thank you.

Tao

[attachment deleted by admin]

Offline golgepapaz

  • Multiple posting newcomer
  • *
  • Posts: 44
Re: warnings when creating a GUI app based on wxWidgets
« Reply #1 on: July 22, 2013, 07:10:01 pm »
what's your gcc version? I've heard 4.8.0  causes such problems.
same thing happened with me with boost. Also mixing optimization flags
does not work the way you expect here, it's the last optimization that is the effective. You can
look up what different optimization flags do here. http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
Unlike previous versions new MSVC also does not let you link libraries optimized with different flags anymore.

Well, in the end, tend to try to use the same flags for your libraries

« Last Edit: July 22, 2013, 07:14:49 pm by golgepapaz »

Offline fancyivan

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: warnings when creating a GUI app based on wxWidgets
« Reply #2 on: July 23, 2013, 05:14:10 am »
Hi, golgepapaz,

my GCC is 4.5.2.

yes, you are right. in gnu docs:

If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.
---------------------------------------------------------------------------------------------------------

do you know how to find out the answer about which GCC version support the above rule?   all GCC version?

Thank you again.

Tao

what's your gcc version? I've heard 4.8.0  causes such problems.
same thing happened with me with boost. Also mixing optimization flags
does not work the way you expect here, it's the last optimization that is the effective. You can
look up what different optimization flags do here. http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
Unlike previous versions new MSVC also does not let you link libraries optimized with different flags anymore.

Well, in the end, tend to try to use the same flags for your libraries