加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

当编译具有大小优化(-Os)的boost_regex时,我收到“重复部分”错

发布时间:2020-12-16 03:15:08 所属栏目:百科 来源:网络整理
导读:编译器: 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/boost/files/boost/1.52.0/boost_1_52_0.7z (D:驱动器
编译器: 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/boost/files/boost/1.52.0/boost_1_52_0.7z

(D:驱动器上)

boost_regex编译为:

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

码:

#include <boostregex.hpp>
int main() {
  boost::regex reg("[a-z]+");
}

编译参数:

g++ -I "d:boost" -Os -o test.exe test.cpp -static -L d:booststagelib -lboost_regex-mt

错误:

d:booststageliblibboost_regex-mt.a(regex.o): duplicate section `.rdata$_ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE[__ZTVN5boost16exception_detail19error_info_injectorISt13runtime_errorEE]' has different size
d:booststageliblibboost_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:booststageliblibboost_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:booststageliblibboost_regex-mt.a(regex.o): duplicate section `.rdata$_ZTSN5boost16exception_detail10clone_baseE[__ZTSN5boost16exception_detail10clone_baseE]' has different size
d:booststageliblibboost_regex-mt.a(regex.o): duplicate section `.rdata$_ZTSN5boost16exception_detail19error_info_injectorISt13runtime_errorEE[__ZTSN5boost16exception_detail19error_info_injectorISt13runtime_errorEE]' has different size

它编译好,但是我还没有测试它是否会在更复杂的代码中工作.删除-Os开关清除错误,但应用程序大小是两倍.

也许我应该使用大小优化构建Boost,但是我不知道在b2命令行中通过此选项的位置.

解决方法

在我的情况下,boost 1.58内部编译为“-march = i686”,但是我的代码没有.将“-march = i686”添加到我的项目中,摆脱了所有的“重复部分”.

经验教训:总是精心确保所有库和主项目都使用相同的编译器选项进行编译.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读