与尺寸优化的编译boost_regex时,我得到了'重复的部分“错误(-Os) [英] I got 'duplicate section' errors when compiling boost_regex with size optimization (-Os)
问题描述
编译器:<一href=\"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\">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
升压:<一href=\"http://sourceforge.net/projects/boost/files/boost/1.52.0/boost_1_52_0.7z\">http://sourceforge.net/projects/boost/files/boost/1.52.0/boost_1_52_0.7z
(无论在D:驱动器)
boost_regex编译:
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]+");
}
与参数编译:
g++ -I "d:\boost" -Os -o test.exe test.cpp -static -L d:\boost\stage\lib -lboost_regex-mt
错误:
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
它编译好,但我还没有测试它是否会在更复杂的code一起工作。删除 -Os
开关清除错误,但应用程序的大小是2倍那么大。
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.
也许我应该建立与尺寸优化加速太也,但我不知道从哪里传中B2命令行这个选项。
Maybe I should build Boost with size optimization too also but I don't know where to pass this option in b2 command line.
推荐答案
在我的情况下提升了1.58与内部-march = i686的编译,但是我的code不是。加入-march = i686的我的项目摆脱了所有的重复节的。
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.
这篇关于与尺寸优化的编译boost_regex时,我得到了'重复的部分“错误(-Os)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!