Opened 13 years ago

Closed 12 years ago

#4075 closed Bugs (invalid)

undefined reference to `_imp__InterlockedExchange' when compiling interprocess example

Reported by: michael.kane@… Owned by: Ion Gaztañaga
Milestone: Boost 1.43.0 Component: interprocess
Version: Boost 1.42.0 Severity: Problem
Keywords: Cc:

Description

When compiling the "doc_named_mutex.cpp" example in boost interprocess (version 1.42.0) with mingw64 version 1.0 build 20100322 on Windows 7 Enterprise, I get the following linker error:

C:\Users\jay\Desktop\boost_1_42_0\libs\interprocess\example> x86_64-w64-mingw32-g++ doc_named_mutex.cpp
C:\Users\jay\AppData\Local\Temp\ccb0rZaR.o:doc_named_mutex.cpp:(.text$_ZN5boost12interprocess6winapi28interlocked_compare_exchangeEPV111[boost::interprocess::winapi::interlocked_compare_exchange(long volatile*, long, long)]+0x25: undefined reference to `_imp__InterlockedCompareExchange'
C:\Users\jay\AppData\Local\Temp\ccb0rZaR.o:doc_named_mutex.cpp:(.text$_ZN5boost12interprocess6winapi28interlocked_compare_exchangeEPV111[boost::interprocess::winapi::interlocked_compare_exchange(long volatile*, long, long)]+0x25: undefined reference to `_imp__InterlockedCompareExchange'
collect2: ld returned 1 exit status

Please note: it is not clear to me if this is a boost interprocess issue or a MinGW64 issue. If it is the latter and I can get a description of the problem, I'm happy to report the bug to the MinGW64 project.

Change History (3)

comment:1 by Steven Watanabe, 13 years ago

Does it work if you compile with -DBOOST_USE_WINDOWS_H?

comment:2 by michael.kane@…, 13 years ago

If I compile with -DBOOST_USE_WINDOWS_H, I get a large number of compiler errors. The first few lines read:

../../../boost/interprocess/detail/win32_api.hpp:501: error: 'win32_find_data_t' has not been declared
../../../boost/interprocess/detail/win32_api.hpp:  In function 'void* boost::interprocess::winapi::find_first_file(const char*, int*)':
../../../boost/interprocess/detail/win32_api.hpp: 502: error: cannot convert 'int*' to '_WIN32_FIND_DATAA*' for argument '2' to 'void* FindFirstFileA(const CHAR*, _WIN32_FIND_DATAA*)'
../../../boost/interprocess/detail/win32_api.hpp:  At global scope:
...

comment:3 by Ion Gaztañaga, 12 years ago

Resolution: invalid
Status: newclosed

You need to link the appropiate mingw libraries for this. In Visual this function is defined in Kernel32.lib

Note: See TracTickets for help on using tickets.