I am trying to use boost streams in mingw (TDM-mingw, 32 bit based on gcc4.6) from qtcreator using qmake. I managed to compile boost 1.4.7 using
bjam --toolset=gcc --layout=tagged --without-mpi --without-python -j 4 stage --build-type=complete
However, I just can't tie it up. I tried linking several libboost_thread libraries created ( libboost_thread.a, libboost_thread-mt.a, libboost_thread-mt-dll.a, libboost_thread-mt-sa
), but that always ends up giving me
ld.exe: warning: cannot find entry symbol nable-stdcall-fixup; defaulting to 00401000 main.o:main.cpp:(.text.startup+0x76): undefined reference to `_imp___ZN5boost6thread12start_threadEv' main.o:main.cpp:(.text.startup+0x89): undefined reference to `_imp___ZN5boost6thread4joinEv' main.o:main.cpp:(.text.startup+0x9c): undefined reference to `_imp___ZN5boost6threadD1Ev' main.o:main.cpp:(.text.startup+0xdb): undefined reference to `_imp___ZN5boost6threadD1Ev'
The code I'm trying to compile is as follows:
#include <boost/thread.hpp> struct thread_main { void operator()(){ std::cout<<"Hello World"<<std::endl; } }; int main(int argc, char* argv[]) { boost::thread thread((thread_main())); thread.join(); return 0; }
The compilation commands created by qmake are as follows:
g++ -c -std=gnu++0x -fopenmp -march=i686 -mtune=generic -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I'e:/Qt/4.73/Desktop/Qt/4.7.3/mingw/include' -I'e:/Qt/4.73/Desktop/Qt/4.7.3/mingw/include/ActiveQt' -I'release' -I'../Test' -I'.' -I'e:/Qt/4.73/Desktop/Qt/4.7.3/mingw/mkspecs/win32-g++' -o main.o ../Test/main.cpp g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-subsystem,console -mthreads -Wl -o Test.exe.exe main.o -L'e:/boost/stage/lib' -L'e:/Qt/4.73/Desktop/Qt/4.7.3/mingw/lib' -fopenmp -l boost_thread
-fopenmp -march = i686 -mtune = generic -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT g++ -c -std=gnu++0x -fopenmp -march=i686 -mtune=generic -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I'e:/Qt/4.73/Desktop/Qt/4.7.3/mingw/include' -I'e:/Qt/4.73/Desktop/Qt/4.7.3/mingw/include/ActiveQt' -I'release' -I'../Test' -I'.' -I'e:/Qt/4.73/Desktop/Qt/4.7.3/mingw/mkspecs/win32-g++' -o main.o ../Test/main.cpp g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-subsystem,console -mthreads -Wl -o Test.exe.exe main.o -L'e:/boost/stage/lib' -L'e:/Qt/4.73/Desktop/Qt/4.7.3/mingw/lib' -fopenmp -l boost_thread
Accordingly , it should be compiled with -DBOOST_THREAD_USE_LIB
, however this only leads to
ld.exe: warning: cannot find entry symbol nable-stdcall-fixup; defaulting to 00401000 main.o:main.cpp:(.text.startup+0x75): undefined reference to `boost::thread::start_thread()' main.o:main.cpp:(.text.startup+0x87): undefined reference to `boost::thread::join()' main.o:main.cpp:(.text.startup+0x99): undefined reference to `boost::thread::~thread()' main.o:main.cpp:(.text.startup+0xd7): undefined reference to `boost::thread::~thread()'
So, how can I convection mingw to reference boost_thread (or if this is a problem with the compilation flags provided to the qmake linker, how can I convince it to omit the problematic flags?