I'm on a fedora 19 x86_64 computer, with mingw64 and all the relevant packages installed. I was working on a personal c++ project, and i decided to make it thread-safe, and so I decided to give Boost.thread synchronization objects a try. As soon as I did, I started to get linker errors related to InterlockedCompareExchange. The following test program illustrates my point:
#include <boost/thread/locks.hpp>
#include <boost/thread/shared_mutex.hpp>
int main()
{
boost::shared_mutex mtx;
boost::unique_lock<decltype(mtx)> lck{mtx};
}
Here's the command line (I put -lboost_thread-mt because there's no non-multithreaded version, which makes sense):
$ x86_64-w64-mingw32-g++ -std=c++11 test.cpp -o test -I/usr/x86_64-w64-mingw32/sys-root/mingw/include -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -lboost_thread-mt -lboost_system
/tmp/cc4Wh6PO.o:test.cpp:(.text$_ZN5boost12shared_mutex28interlocked_compare_exchangeINS0_10state_dataEEET_PS3_S3_S3_[_ZN5boost12shared_mutex28interlocked_compare_exchangeINS0_10state_dataEEET_PS3_S3_S3_]+0x2f): undefined reference to `InterlockedCompareExchange' collect2: error: ld returned 1 exit status
But with mingw32 it compiles like a charm:
$ i686-w64-mingw32-g++ -std=c++11 test.cpp -o test -I/usr/i686-w64-mingw32/sys-root/mingw/include -L/usr/i686-w64-mingw32/sys-root/mingw/lib -lboost_thread-mt -lboost_system
My question is: am I doing something wrong or is it a bug in mingw64? Does it compile with the windows version of mingw?
Edit: actually it did, so it must be a bug in the fedora mingw64 package