Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Compiler threading support is not turned on."

Normally I can google my way around and find solutions, but not this time.

I'm using 64 bit Linux Ubuntu 11.04 to compile a 32 bit windows application. I'm using i586-mingw32msvc-gcc to compile my C++ files.

test.cpp:

#include <boost/asio.hpp>

makefile:

i586-mingw32msvc-gcc -c -m32 -mthreads -o test.o test.cpp

Error:

boost/asio/detail/socket_types.hpp:
# include <sys/ioctl.h>
doesn't exist.

Added to makefile: -DBOOST_WINDOWS

Error:
#   warning Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately

Ok, added to makefile: -D_WIN32_WINNT=0x0501

Error:
#   error "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"

Yet I did specify -mthreads.

like image 637
Mike Avatar asked Nov 07 '11 21:11

Mike


2 Answers

Adding -DBOOST_HAS_THREADS might be sufficient (see # elif defined __GNUC__ from the offending header). But it's likely/possible that your boost installation has been crafted to support your build environment and not your target. Try building it yourself with your cross-compiling toolchain.

like image 64
Brian Cain Avatar answered Oct 24 '22 00:10

Brian Cain


It turned out that I had a set of #undef and #defines to force the GLIBC version to something that allowed me to compile for Linux (not cross compile) RHEL5, which otherwise would give me all kinds of other errors. Turns out that when cross compiling for windows using mingw, that force feeding the GLIBC version causes boost to take a strange path leaving various aspects undefined, including the bahavior or availability of threading. I surrounded it with an #ifndef _WIN32 which made the problem go away.

like image 32
Mike Avatar answered Oct 24 '22 00:10

Mike