Opened 19 years ago

Closed 19 years ago

#219 closed Bugs (Works For Me)

Threads not detected in mingw build

Reported by: tarvin Owned by: nobody
Milestone: Component: None
Version: None Severity:
Keywords: Cc:

Description

Using boost on Windows 2000 with the mingw compiler. 
Compiling like this works fine:
bjam -sTOOLS=mingw

I copy the threaded release-dlls to a relevant place and 
start using Boost.Thread. My code (which uses 
Boost.Thread) works fine on Linux. When compiling with 
mingw, I get a lot of lines like this:

In file included from headers/Position.h:10, from 
main.cpp:7:
C:/boost/boost/thread/thread.hpp:17:5: #error Thread 
support is unavailable!

Tested with Boost 1.30.2 and latest CVS as of December 
9 2003.

If I compile with
-DBOOST_HAS_THREADS
and
-DBOOST_HAS_WINTHREADS

Then I get some warnings about the above constants 
being redefined, but things work fine.

I believe that mingw is not recognized as a platform 
supporting native win32 threads, which is an error, as 
far as I know.

By the way: I tried running "configure" with 
BOOST_HAS_WINTHREADS=1 as described on 
http://boost.org/libs/config/config.htm#configuring but 
that didn't help.

Change History (3)

comment:1 by John Maddock, 19 years ago

Logged In: YES 
user_id=14804

You need to turn on threading support in your compiler - that 
means using -mthreads on mingw32 I believe.

John Maddock

comment:2 by tarvin, 19 years ago

Logged In: YES 
user_id=831453

I cannot find a way to turn on threading in a way which
boost understands. I want to add "-mthreads -mwindows" to
the build flags. I tried using bjam's -sBUILD="release
<cxxflags>-mthreads -mwindows" but that didn't work: bjam
seems to only pick up the first flag. I have searched for a
while but cannot find a way to add more than one g++-flag
this way.

Anyways, I'm now using
bjam -sTOOLS=mingw -sBUILD=release -sGXX="g++ -mthreads
-mwindows -march=i686" which results in compile steps like:

g++  -mthreads -mwindows -march=i686  -c -Wall
-ftemplate-depth-100  -DNDEBUG -DNDEBUG
-DBOOST_SIGNALS_NO_LIB=1  -O3 -finline-functions -Wno-inline
  -I"binoostlibssignalsuild"  -I "C:oost"  -o
"binoostlibssignalsuildlibboost_signals.libmingweleasesignal_base.obj"
 "C:/boost/libs/signals/build/../src/signal_base.cpp"

All looks fine, I should think, but boost still doesn't
recognize thread support: I still get the before mentioned
errors when building software using Boost.Threads.

How does boost detect if threading is available?

comment:3 by John Maddock, 19 years ago

Status: assignedclosed
Logged In: YES 
user_id=14804

I've checked this with the current cvs state (soon to be 
released), and bjam does insert the required -mthreads 
argument for Jamfile targets with a <threading>multi 
requirement.

John.
Note: See TracTickets for help on using tickets.