c++ - 使用 mingw-w64 工具链时,以 Release模式链接的 Regex Boost 库会发出 "duplicate section has different size"警告

标签 c++ boost mingw-w64

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

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 在构建期间没有输出这些选项)。

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

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

为了在我的项目中编译文件,我使用类似的东西

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

我的测试表明正则表达式运行良好,但我仍然想解决警告。

编辑

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

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

也许确保将与我所做的相同的参数传递给项目可以解决问题(特别是与链接问题中建议的优化相关的参数)。

最佳答案

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

关于c++ - 使用 mingw-w64 工具链时,以 Release模式链接的 Regex Boost 库会发出 "duplicate section has different size"警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11635485/

相关文章:

javascript - QML:将 JS 对象传递给 C++ 成员函数

c++ - 向 brent_find_minima 添加额外的参数

c++ - 错误: sigjmp_buf does not name a type. When Compiling my project with Poco C++ libraries

CMake 无法静态链接 SDL2

C++ boost::bind 占位符位置

c++ - 在 C++ 中按降序打印 map 值

c++ - 在 C++ 中将文件读入内存的最快方法?

c++ - Spirit.X3 使用 string_view 和名为 'insert' 的成员编译错误

c++ - 如何在 QT Creator 中运行 Boost 单元测试?

makefile - 如何在 Windows-10 上编译 REDIS 5.0.5,make 出错