发布模式下的 Regex Boost 库链接警告“重复部分的大小不同"使用 mingw-w64 工具链时

2021-12-24 00:00:00 mingw-w64 c++ boost

在发布模式下链接我的项目时,我收到以下警告:

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

我怀疑原因可能是 boost 库的编译选项与我在项目中使用的选项不同,但我不知道如何找到差异(boost 在构建过程中没有输出这些选项).

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).

为了在 Ubuntu 12.04 上为 win32 编译 boost 我使用了这个程序:

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.

编辑

我发现可以使用 bjam 的 cxxflags= 参数为 boost 编译器添加其他选项.

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

示例:bjam cxxflags='-fPIC' ....

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).

推荐答案

你的编译器是用不同的选项编译的 :) 在 Linux 上编译库和在 Windows 上编译程序会导致存在同名 .data 段的情况,但它们的大小不一样.这在理论上可能很有趣,因为数据段是可写的,但实际上,这无关紧要.除非有证据表明这会导致我不知道的问题,否则您可以安全地取消该警告;不过,我不知道你是如何让它消失的.

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.

相关文章