Boost logo

Boost Users :

Subject: Re: [Boost-users] [thread] mingw32: multiple definition of __tls_used
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2010-06-11 08:10:23


Frédéric Bron <frederic.bron_at_[hidden]> writes:

> I have some troubles with mingw32 (compiling from cygwin with g++ 3.4.4):
>
> The code below fails at link with following error message:
> /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/lib/libmingw32.a(tlssup.o):tlssup.c:(.tls+0x0):
> multiple definition of `__tls_used'
> /cygdrive/d/Softs/1.7/mgw-release/boost/lib/libboost_thread_win32.a(tss_pe.o):tss_pe.cpp:(.rdata$T+0x0):
> first defined here
> collect2: ld returned 1 exit status
>
> #include <boost/thread/tss.hpp>
> int main() {
> boost::thread_specific_ptr<int> tsp;
> return 0;
> }
>
> Compiling command was:
> $ g++-3 -o toto -O3 -DNDEBUG -mno-cygwin -mthreads -DBOOST_WINDOWS_API
> -I/cygdrive/d/Softs/1.7/mgw-release/boost/include toto.cc
> -L/cygdrive/d/Softs/1.7/mgw-release/boost/lib -lboost_thread_win32
>
> Recently, mingw32 runtime was updated for cygwin with the following message:
>
>> Implement TLS Callback.
>>
>> * tlsmcrt.c: New file.
>> * tlsmthread.c: Ditto.
>> * tlssup.c: Ditto.
>> * tlsthrd.c: Ditto.
>> * Makefile.in: Include new files.
>> * crt1.c: Implement TLS Callback.
>> * dllcrt1.c: Ditto.
>> * mthr_stub.c: Remove.
>
> Any clue?

The mingw32 runtime has started implementing the tls callback
stuff. Boost.Thread currently does this manually for mingw, so this
clashes with the new runtime library.

I'll have to look into this to see if this can be detected in
boost.thread based on some version flag in the mingw headers or
something, and if so how to ensure that the boost.thread callbacks get
invoked.

Anthony

-- 
Author of C++ Concurrency in Action     http://www.stdthread.co.uk/book/
just::thread C++0x thread library             http://www.stdthread.co.uk
Just Software Solutions Ltd       http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net