在mingw32上增加线程创建InterlockedCompareExchange错误

时间:2014-09-28 17:01:53

标签: c++ boost-asio

在使用Google搜索InterlockedCompareExchange错误后,似乎它始终指向mingw64的旧错误,而我正在使用mingw32。

似乎所有使用线程的示例都会发生,但如果我只是#34; #include <boost/thread.hpp>&#34;并且没有线程的调用它会工作,所以我认为我做了正确的链接。

这是我的构建:

-------------- Build: Debug in UDP_EXAMPLE (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -D_WIN32_WINNT=0x0501 -g -IC:\boost_1_56_0 -c "C:\Users\poteto\Desktop\Other Programming\UDP_EXAMPLE\server.cpp" -o obj\server.o
In file included from C:\boost_1_56_0/boost/thread/win32/thread_data.hpp:11:0,
                 from C:\boost_1_56_0/boost/thread/thread_only.hpp:15,
                 from C:\boost_1_56_0/boost/thread/thread.hpp:12,
                 from C:\boost_1_56_0/boost/thread.hpp:13,
                 from C:\Users\poteto\Desktop\Other Programming\UDP_EXAMPLE\server.cpp:5:
C:\boost_1_56_0/boost/thread/win32/thread_primitives.hpp:180:0: warning: ignoring #pragma intrinsic  [-Wunknown-pragmas]
mingw32-g++.exe  -o Debug\http_server.exe obj\server.o  -lws2_32 -lwsock32  C:\boost_1_56_0\stage\lib\libboost_thread-mgw47-mt-1_56.a C:\boost_1_56_0\stage\lib\libboost_system-mgw47-mt-1_56.a
C:\boost_1_56_0\stage\lib\libboost_thread-mgw47-mt-1_56.a(thread.o):thread.cpp:(.text$_ZN5boost6detail5win3223GetTickCount64emulationEv+0x1e): undefined reference to `_InterlockedCompareExchange'
C:\boost_1_56_0\stage\lib\libboost_thread-mgw47-mt-1_56.a(thread.o):thread.cpp:(.text$_ZN5boost6detail5win3223GetTickCount64emulationEv+0x70): undefined reference to `_InterlockedCompareExchange'
C:\boost_1_56_0\stage\lib\libboost_thread-mgw47-mt-1_56.a(thread.o):thread.cpp:(.text$_ZN5boost6detail5win3223GetTickCount64emulationEv+0xb5): undefined reference to `_InterlockedCompareExchange'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 11 second(s))
3 error(s), 1 warning(s) (0 minute(s), 11 second(s))

我链接了库:libboost_thread和libboost_system。我正在使用Codeblocks。没有线程的其他asio示例。

在示例中:http://www.ce.unipr.it/~medici/udpserver2.html

如果我要删除对该线程的调用,它将起作用。

0 个答案:

没有答案