Mingw32 Boost日志链接错误:InterlockedCompareExchange

时间:2014-10-05 17:37:29

标签: c++ boost mingw

您好我正在尝试在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

我一直试图将此链接连接好几天,并且没有在互联网上找到任何修复链接错误的内容。

有人可以帮忙吗?

2 个答案:

答案 0 :(得分:0)

拼接来自不同网站的信息:

答案 1 :(得分:0)

Mingw-W64的安装程序无法正常工作,但在我手动从存储库下载后,我能够正常工作。我为mingw版本4.9.1重建了boost库,然后它确实链接到了新库。非常感谢!哇噢!