11

When linking my project in the release mode I am getting the following warning:

myProject-libs/release/libboost_regex-mt-s-1.50.0.a(cpp_regex_traits.o): duplicate section `.data$_ZZN5boost16cpp_regex_traitsIcE21get_catalog_name_instEvE6s_name[boost::cpp_regex_traits<char>::get_catalog_name_inst()::s_name]' has different size

I suspect that the cause could be that the boost library is compiled with different options than I use for my project, but I don't know how to find the difference (boost didn't output these options during the build).

In order to compile the boost for win32 on Ubuntu 12.04 I used this procedure:

tar jxf boost_1_50_0.tar.bz2
cd boost_1_50_0
./bootstrap.sh
echo "using gcc : 4.6 : i686-w64-mingw32-g++ : <rc>i686-w64-mingw32-windres <archiver>i686-w64-mingw32-ar ;" > user-config.jam
./bjam toolset=gcc target-os=windows --address-model=32 variant=release threading=multi threadapi=win32 link=static runtime-link=static --prefix=/opt/boost_1_50_0-release-static-windows-32 --user-config=user-config.jam -j 10 --without-mpi --without-python -sNO_BZIP2=1 -sNO_ZLIB=1 --layout=tagged install

In order to compile files in my project I use something like

i686-w64-mingw32-g++ -march=corei7 -mfpmath=sse -m32 -Wall -fmessage-length=0 -I"/opt/boost_1_50_0-release-static-windows-32/include" -std=c++0x -O3 -g0 -DNDEBUG -I"myProject/src/cpp" -c -o myProject/build/release/src/cpp/myproject.o myproject/src/cpp/myproject.cpp

The tests I have indicate that the regexps run fine but still I would like to resolve the warning.

EDIT

I found that additional options to the boost compiler can be added using a cxxflags= argument of bjam.

Example: bjam cxxflags='-fPIC' ....

Maybe making sure to pass the same arguments as I do to the project could resolve the problem (particularly the arguments related to optimizations as suggested in the linked question).

David L.
  • 3,149
  • 2
  • 26
  • 28
  • 1
    You managed to compile boost so neatly in linux with that command line!? Last time I tried it took me several hours. I'm upvoting your question just because of that. – dsign Jul 25 '12 at 04:44
  • 1
    It was not really me, just copy&paste from already forgotten page, but it also took me a long time to find such a nice short code between thousands of scattered tips and tricks. – David L. Jul 25 '12 at 13:55
  • 4
    i have also got this 'problem' on windows 7 64 with mingw-w64 (gcc 4.7.1, boost 1.51.0), but not with mingw (gcc 4.7.0). maybe this is a problem of mingw-w64? – user573335 Oct 07 '12 at 21:10
  • 1
    The problem arises on mingw (gcc version 4.8.3 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)) too. All TUs compiled with the same options and `ar`-ed into one `.a` file, but when `.a` linked against else one `.o` file, then similar error arises. The library `.a` hardly uses *Boost.Spirit* internally. – Tomilov Anatoliy May 27 '14 at 07:37
  • http://stackoverflow.com/a/24233374/1073006 – Lorenzo Pistone Jun 15 '14 at 19:37

2 Answers2

3

Your compilers were compiled with different options :) Compiling the library on Linux and the program on Windows result in a situation where there is an identically named .data segment, but they aren't the same size. That could theoretically be interesting, inasmuch as a data segment is writable, but in practice, it shouldn't matter. Unless there is evidence to suggest this causes a problem of which I'm not aware, you can safely suppress that warning; I don't know how you'd make it go away, though.

Ben Brammer
  • 988
  • 4
  • 11
  • 3
    In the past I possibly used slightly different versions of the compilers, but now I am sure that boost is compiled with the same compiler as the project and I have still the warnings. – David L. Nov 23 '13 at 00:30
  • I've found that having some parts of the project compiled with -Os and others without optimizations trigger this problem, also if the same compiler is used. – gabry Jan 30 '14 at 09:22
0

I recently encountered this problem (i.e. linker warning "duplicate section has different size") when trying to compile boost for Windows using mingw.

The issue I had was that I compiled my application with -std=c++14 but when compiling boost I didn't specifically provide a dialect flag (which defaulted to -std=c++98 for g++ 5.3.0). Adding the dialect flag -std=c++14 when compiling boost solved the problem for me. See this answer for an explaination on how to set cxxflags when compiling boost.

I believe my solution might have worked for you (your application was compiled with -std=c++0x but boost was not provided any dialect flag). Although I am 6 years too late, I'll leave my answer here for others who happen to stumble-upon this issue.

J. Borgh
  • 51
  • 4