Hi,
I am trying to cross-compile from linux 64 bits to windows 64 bits. I
am using fedora 19 with -std=c++11 and boost 1.53.0 that comes with
fedora. The compiler is x86_64-w64-mingw32-g++.
The compile flags I use: -O3 -DNDEBUG -DWINDOWS -std=c++11 -Wall
-Wextra -pipe -ffloat-store -DBOOST_DISABLE_ASSERTS
-DBOOST_FILESYSTEM_VERSION=3 -DBOOST_FILESYSTEM_NO_DEPRECATED
-DBOOST_THREAD_USE_LIB
and a typical link command:
$ x86_64-w64-mingw32-g++ -o foo.exe bar1.o bar2.o
-Wl,--enable-auto-import -static -lboost_system-mt
-lboost_filesystem-mt -lboost_thread-mt -lboost_chrono-mt -mthreads
I then get the following errors (each line multiple times with
different .text+0x###):
/usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/libboost_thread-mt.a(thread.o):(.text+0x286):
undefined reference to `InterlockedIncrement'
/usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/libboost_thread-mt.a(thread.o):(.text+0x3e7):
undefined reference to `InterlockedDecrement'
/usr/lib64/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld:
/usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/libboost_thread-mt.a(thread.o):
bad reloc address 0x8 in section `.data'
collect2: error: ld returned 1 exit status
make: *** [mgw64-release/bin/transpose.exe] Erreur 1
I see that this may come from but I
have no idea what this header is used for.
This is what remains after the pre-processor phase (g++ -E):
# 1 "/usr/x86_64-w64-mingw32/sys-root/mingw/include/boost/detail/interlocked.hpp"
1 3 4
# 137 "/usr/x86_64-w64-mingw32/sys-root/mingw/include/boost/detail/interlocked.hpp"
3 4
namespace boost {
namespace detail {
extern "C" long InterlockedIncrement( long volatile * );
extern "C" long InterlockedDecrement( long volatile * );
extern "C" long InterlockedCompareExchange( long volatile *, long, long );
extern "C" long InterlockedExchange( long volatile *, long );
extern "C" long InterlockedExchangeAdd( long volatile *, long );
extern "C" void* InterlockedCompareExchangePointer( void* volatile *,
void*, void* );
extern "C" void* InterlockedExchangePointer( void* volatile *, void* );
}
}
Note that targeting windows 32 bits works allright but the result of
the pre-processor phase is slightly different:
# 1 "/usr/i686-w64-mingw32/sys-root/mingw/include/boost/detail/interlocked.hpp"
1 3 4
# 137 "/usr/i686-w64-mingw32/sys-root/mingw/include/boost/detail/interlocked.hpp"
3 4
namespace boost {
namespace detail {
extern "C" __attribute__((dllimport)) long
__attribute__((__stdcall__)) InterlockedIncrement( long volatile * );
extern "C" __attribute__((dllimport)) long
__attribute__((__stdcall__)) InterlockedDecrement( long volatile * );
extern "C" __attribute__((dllimport)) long
__attribute__((__stdcall__)) InterlockedCompareExchange( long volatile
*, long, long );
extern "C" __attribute__((dllimport)) long
__attribute__((__stdcall__)) InterlockedExchange( long volatile *,
long );
extern "C" __attribute__((dllimport)) long
__attribute__((__stdcall__)) InterlockedExchangeAdd( long volatile *,
long );
}
}
Frédéric