Boost logo

Threads-Devel :

Subject: [Threads-devel] building boost.thread 1.44 on windows with MinGW 4.5 64 bit
From: Guillaume Chatelet (chatelet.guillaume_at_[hidden])
Date: 2010-08-18 14:13:02


Hi there,

I'd like to build boost 1.44 on windows 64 bit with GCC 4.5
I'm using TDM-GCC releases : http://tdm-gcc.tdragon.net/download
More precisely the tdm64-gcc-4.5.0 : http://sourceforge.net/projects/tdm-
gcc/files/TDM-GCC%20Installer/tdm64-gcc-4.5.0.exe/download

When compiling the thread library with bjam - either in 32 and 64 memory address
model - the compilation fails with the following trace.

For 32bits memory address model :
 L:\boost_1_44_0>bjam.exe -d2 --toolset=gcc address-model=32 thread
 ...patience...
 ...found 511 targets...
 ...updating 3 targets...
 gcc.compile.c++ bin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\address-model-32\threading-multi\win32\thread.o

     "g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -mthreads -m32 -Wno-long-long -DBOOST_ALL_NO_LIB=1 -DBOOST_THREAD_BUILD_DLL=1 -I"." -c -o "bin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\address-model-32\threading-
multi\win32\thread.o" "libs\thread\src\win32\thread.cpp"

 In file included from ./boost/thread/once.hpp:14:0,
                  from libs\thread\src\win32\thread.cpp:17:
 ./boost/thread/win32/once.hpp: In function 'void boost::call_once(boost::once_flag&, Function)':
 ./boost/thread/win32/once.hpp:136:20: error: '_InterlockedCompareExchange' is not a member of 'boost::detail'
 ./boost/thread/win32/once.hpp:152:25: error: '_InterlockedIncrement' is not a member of 'boost::detail'
 ./boost/thread/win32/once.hpp:155:21: error: '_InterlockedExchange' is not a member of 'boost::detail'
 ./boost/thread/win32/once.hpp:169:21: error: '_InterlockedExchange' is not a member of 'boost::detail'
 ./boost/thread/win32/once.hpp:184:17: error: '_InterlockedIncrement' is not a member of 'boost::detail'
 ...failed gcc.compile.c++ bin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\address-model-32\threading-multi\win32\thread.o...
 ...skipped <pbin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\address-model-32\threading-multi>libboost_thread-mgw45-mt-d-1_44.dll.a for lack of <pbin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\address-model-32\threading-
multi>win32\thread.o...
 ...skipped <pbin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\address-model-32\threading-multi>libboost_thread-mgw45-mt-d-1_44.dll for lack of <pbin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\address-model-32\threading-
multi>win32\thread.o...
 ...failed updating 1 target...
 ...skipped 2 targets...

For 64bits memory address model :

 L:\boost_1_44_0>bjam.exe -d2 --toolset=gcc address-model=64 thread
 ...patience...
 ...found 511 targets...
 ...updating 3 targets...
 gcc.compile.c++ bin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\address-model-64\threading-multi\win32\thread.o

     "g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -mthreads -m64 -Wno-long-long -DBOOST_ALL_NO_LIB=1 -DBOOST_THREAD_BUILD_DLL=1 -I"." -c -o "bin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\address-model-64\threading-
multi\win32\thread.o" "libs\thread\src\win32\thread.cpp"

 In file included from ./boost/thread/win32/basic_timed_mutex.hpp:14:0,
                  from ./boost/thread/win32/mutex.hpp:8,
                  from ./boost/thread/mutex.hpp:14,
                  from ./boost/thread/detail/thread.hpp:13,
                  from ./boost/thread/thread.hpp:22,
                  from libs\thread\src\win32\thread.cpp:10:
 ./boost/thread/win32/interlocked_read.hpp: In function 'void boost::detail::interlocked_write_release(void* volatile*, void*)':
 ./boost/thread/win32/interlocked_read.hpp:71:13: error: cast from 'void*' to 'long int' loses precision
 In file included from ./boost/thread/win32/mutex.hpp:8:0,
                  from ./boost/thread/mutex.hpp:14,
                  from ./boost/thread/detail/thread.hpp:13,
                  from ./boost/thread/thread.hpp:22,
                  from libs\thread\src\win32\thread.cpp:10:
 ./boost/thread/win32/basic_timed_mutex.hpp: In member function 'void* boost::detail::basic_timed_mutex::get_event()':
 ./boost/thread/win32/basic_timed_mutex.hpp:183:43: error: cast from 'void*' to 'long int' loses precision
 In file included from ./boost/thread/once.hpp:14:0,
                  from libs\thread\src\win32\thread.cpp:17:
 ./boost/thread/win32/once.hpp: In function 'void boost::call_once(boost::once_flag&, Function)':
 ./boost/thread/win32/once.hpp:136:20: error: '_InterlockedCompareExchange' is not a member of 'boost::detail'
 ./boost/thread/win32/once.hpp:152:25: error: '_InterlockedIncrement' is not a member of 'boost::detail'
 ./boost/thread/win32/once.hpp:155:21: error: '_InterlockedExchange' is not a member of 'boost::detail'
 ./boost/thread/win32/once.hpp:169:21: error: '_InterlockedExchange' is not a member of 'boost::detail'
 ./boost/thread/win32/once.hpp:184:17: error: '_InterlockedIncrement' is not a member of 'boost::detail'
 ...failed gcc.compile.c++ bin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\address-model-64\threading-multi\win32\thread.o...
 ...skipped <pbin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\address-model-64\threading-multi>libboost_thread-mgw45-mt-d-1_44.dll.a for lack of <pbin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\address-model-64\threading-
multi>win32\thread.o...
 ...skipped <pbin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\address-model-64\threading-multi>libboost_thread-mgw45-mt-d-1_44.dll for lack of <pbin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\address-model-64\threading-
multi>win32\thread.o...
 ...failed updating 1 target...
 ...skipped 2 targets...

As you may notice, the 64 bit version exhibit two supplementary errors :
 ./boost/thread/win32/interlocked_read.hpp:71:13: error: cast from 'void*' to 'long int' loses precision
 ./boost/thread/win32/basic_timed_mutex.hpp:183:43: error: cast from 'void*' to 'long int' loses precision

It looks like a preprocessor issue to me. The file declaring the "interlocked"
functions is 'L:\MinGW64\x86_64-w64-mingw32\include\winbase.h'.
I will try to add it as an attachment as well as a list of the #define issued by
this compiler's preprocessor in 32 and 64 memory address model.

Please tell me if you need any other information.

Best regards,
Guillaume Chatelet


Threads-Devel list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk