您好我正在尝试在Windows 8上将Boost Log简单示例与mingw32相关联,并且我收到链接错误:
Log.cpp
#include <boost/log/trivial.hpp>
int main()
{
BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
BOOST_LOG_TRIVIAL(debug) << "A debug severity message";
BOOST_LOG_TRIVIAL(info) << "An informational severity message";
BOOST_LOG_TRIVIAL(warning) << "A warning severity message";
BOOST_LOG_TRIVIAL(error) << "An error severity message";
BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message";
}
我正在运行以下编译和链接命令
gcc -Wall -g -static -I./../../boost_1_56_0/ Log.cpp -o Log.exe -L./../../boost_1_56_0/stage/lib/ -lboost_log-mgw48-mt-1_56 -lboost_thread-mgw48-mt-1_56 -lboost_system-mgw48-mt-1_56 -lstdc++
我收到以下错误:
C:\SpellSpindle\GelatinousEngine\BoostHelloWorld\Log>mingw32-make
g++ -Wall -g -static -I./../../boost_1_56_0/ Log.cpp -o Log.exe -L./../../boost_
1_56_0/stage/lib/ -lboost_log-mgw48-mt-1_56 -lboost_thread-mgw48-mt-1_56 -lboost
_system-mgw48-mt-1_56 -lstdc++
./../../boost_1_56_0/stage/lib/\libboost_thread-mgw48-mt-1_56.a(thread.o):thread
.cpp:(.text$_ZN5boost6detail5win3223GetTickCount64emulationEv+0x1e): undefined r
eference to `_InterlockedCompareExchange'
./../../boost_1_56_0/stage/lib/\libboost_thread-mgw48-mt-1_56.a(thread.o):thread
.cpp:(.text$_ZN5boost6detail5win3223GetTickCount64emulationEv+0x77): undefined r
eference to `_InterlockedCompareExchange'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: ./../../bo
ost_1_56_0/stage/lib/\libboost_thread-mgw48-mt-1_56.a(thread.o): bad reloc addre
ss 0x77 in section `.text$_ZN5boost6detail5win3223GetTickCount64emulationEv'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link
failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
Makefile:15: recipe for target 'all' failed
mingw32-make: *** [all] Error 1
我一直试图将此链接连接好几天,并且没有在互联网上找到任何修复链接错误的内容。
有人可以帮忙吗?
答案 0 :(得分:0)
拼接来自不同网站的信息:
你不能混合用MinGW 4.7和MinGW 4.8构建的库(OP简单地用4.8对应的不兼容的4.7-.dll替换,即libgomp-1.dll和libstdc ++ 6.dll,让事情奏效);
这只是意味着,使用相同版本的MingW构建提升(另请参阅http://sourceforge.net/apps/trac/mingw-w64/wiki/Building%20Boost了解有关在MingW上构建Boost的想法)
这是关于这种向后兼容性破坏的后台主题 更改:http://lists.qt-project.org/pipermail/releasing/2013-September/001442.html
答案 1 :(得分:0)
Mingw-W64的安装程序无法正常工作,但在我手动从存储库下载后,我能够正常工作。我为mingw版本4.9.1重建了boost库,然后它确实链接到了新库。非常感谢!哇噢!