[英]Mingw32 Boost Log Link Errors: InterlockedCompareExchange
嗨,我試圖將Boost Log簡單示例與Windows 8上的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
我已經嘗試將其鏈接幾天了,卻沒有發現互聯網上發布的任何可解決鏈接錯誤的信息。
有人可以幫忙嗎?
將來自不同網站的信息拼接在一起:
您不能混合使用MinGW 4.7和MinGW 4.8構建的庫(OP只是用4.8對應的libgomp-1.dll和libstdc ++ 6.dll替換了不兼容的4.7-.dll),這些使工作正常。
這僅意味着使用相同版本的MingW構建Boost(有關在MingW上構建Boost的想法,另請參見http://sourceforge.net/apps/trac/mingw-w64/wiki/Building%20Boost )
這是有關此向后兼容突破性更改的后台線程: http : //lists.qt-project.org/pipermail/releasing/2013-September/001442.html
Mingw-W64的安裝程序無法正常運行,但是當我從存儲庫中手動下載該安裝程序后,我可以使該程序正常運行。 我為mingw版本4.9.1重建了boost庫,然后將其鏈接到新庫。 非常感謝! hoo!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.