compiler: http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.7.2/32-bit/threads-posix/sjlj/x32-4.7.2-release-posix-sjlj-rev6.7z
boost: http://sourceforge.net/projects/boost/files/boost/1.52.0/boost_1_52_0.7z
(both on D: drive)
boost_regex compiled with:
b2 --prefix=D:\boost toolset=gcc --with-regex --layout=tagged release
code:
#include <boost\regex.hpp>
int main() {
boost::regex reg("[a-z]+");
}
compiled with parameters:
g++ -I "d:\boost" -Os -o test.exe test.cpp -static -L d:\boost\stage\lib -lboost_regex-mt
error:
d:\boost\stage\lib\libboost_regex-mt.a(regex.o): duplicate section `.rdata$_ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE[__ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE]' has different size
d:\boost\stage\lib\libboost_regex-mt.a(regex.o): duplicate section `.rdata$_ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEEE[__ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEEE]' has different size
d:\boost\stage\lib\libboost_regex-mt.a(regex.o): duplicate section `.rdata$_ZTSN5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEEE[__ZTSN5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEEE]' has different size
d:\boost\stage\lib\libboost_regex-mt.a(regex.o): duplicate section `.rdata$_ZTSN5boost16exception_detail10clone_baseE[__ZTSN5boost16exception_detail10clone_baseE]' has different size
d:\boost\stage\lib\libboost_regex-mt.a(regex.o): duplicate section `.rdata$_ZTSN5boost16exception_detail19error_info_injectorISt13runtime_errorEE[__ZTSN5boost16exception_detail19error_info_injectorISt13runtime_errorEE]' has different size
It compiles ok, but I haven't yet tested if it will be working in more complex code. Removing the -Os
switch clears the error but app size is 2x bigger then.
Maybe I should build Boost with size optimization too also but I don't know where to pass this option in b2 command line.
In my case boost 1.58 was internally compiling with "-march=i686", but my code wasn't. Adding "-march=i686" to my project got rid of all "duplicate section".
lesson learned: always make painstakingly sure that all libraries and the main project are compiled with identical compiler options.
I believe this is a compiler bug. The workaround in my case was to add -fno-tree-vectorize
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With