Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我得到了';重复部分';使用大小优化(-Os)编译boost_regex时出错_Boost_Mingw_Compiler Optimization - Fatal编程技术网

我得到了';重复部分';使用大小优化(-Os)编译boost_regex时出错

我得到了';重复部分';使用大小优化(-Os)编译boost_regex时出错,boost,mingw,compiler-optimization,Boost,Mingw,Compiler Optimization,编译器: 促进: (都在D:驱动器上) boost_regex编译时使用: b2 --prefix=D:\boost toolset=gcc --with-regex --layout=tagged release 代码: 错误: d:\boost\stage\lib\libboost_regex-mt.a(regex.o): duplicate section `.rdata$_ZTVN5boost16exception_detail19error_info_injectorISt13run

编译器:

促进:

(都在D:驱动器上)

boost_regex编译时使用:

b2 --prefix=D:\boost toolset=gcc --with-regex --layout=tagged release
代码:

错误:

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
它可以编译,但我还没有测试它是否可以在更复杂的代码中工作。移除
-Os
开关可清除错误,但应用程序大小比此大2倍


也许我也应该使用大小优化来构建Boost,但我不知道在b2命令行中向何处传递此选项。

我认为这是一个编译器错误。在我的案例中,解决方法是添加
-fno树向量化

在我的案例中,boost 1.58是使用“-march=i686”进行内部编译的,但我的代码不是。将“-march=i686”添加到我的项目中,消除了所有“重复部分”


经验教训:始终要确保所有库和主项目都使用相同的编译器选项进行编译。

当我使用MinGW32中的gcc-4.9.1和使用gcc-4.4.7作为编译器的库编译代码时,我遇到了相同的错误。我也用了ccache来加速,ccache也是个问题。删除~/.ccache/中的缓存并重新编译,然后我解决了这个问题

他也有同样的问题。其中一条评论指出,问题可能与mingw-w64无关。Mingw build的g++4.8.0也出现了这个问题,fedora 17的g++4.7.2则没有,因此他/她可能是对的。正如您所说,使用大小优化(将
optimization=space
添加到boost build命令中)似乎可以消除这个问题。如果你能确认它有效,你应该把它作为一个答案。PS:好吧,现在问题正好相反,只要你不使用
-Os
@llonesmiz:谢谢!这很有效。问题是我找不到这个选项,它不是由
b2--help
--help options
打印的。如果您计划只使用g++(或接受相同命令行标志的编译器),您也可以使用
cxflags=-Os
。还有
linkflags
将选项传递给链接器。我对Crypto++也有同样的问题。和MinGW和MinGW-w64都有。我也一样。在增压1.57和1.58之间,这一定是无声的变化。我花了一些时间找到它。“-march=i686”与mingw一起为crypto++工作。谢谢
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