Opened 8 years ago

Closed 6 years ago

#4258 closed Bugs (fixed)

Linking with boost thread does not work on mingw/gcc 4.5

Reported by: Danil Ilinykh <woodroof@…> Owned by: viboes
Milestone: Boost 1.51.0 Component: thread
Version: Boost 1.49.0 Severity: Showstopper
Keywords: Cc: Bryce Lelbach


Errors: c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../libmingw32.a(tlssup.o):tlssup.c:(.tls+0x0): multiple definition of `_tls_used' C:\boost\mingw/Lib/libboost_thread.a(tss_pe.o):tss_pe.cpp:(.rdata$T+0x0): first defined here

Change History (16)

comment:1 Changed 8 years ago by Danil Ilinykh <woodroof@…>

If I try dynamic linking, it works well, but I get error while executing application: The application failed to initialize properly (0xc0000005)

comment:2 Changed 8 years ago by Danil Ilinykh <woodroof@…>

This bug is introduced by mingwrt-3.18-mingw32. With mingwrt-3.17-mingw32 all works fine.

comment:3 Changed 8 years ago by anonymous

Duplicated of #3847?

comment:4 Changed 8 years ago by aszarsha

you have to add this definition to your code: extern "C" void tss_cleanup_implemented() { }

comment:5 Changed 8 years ago by anonymous

When adding some preprocessor checks in tss_pe.cpp that prevent the declaration _tls_used for MinGW, I've been able to fix this problem! All I did was to wrap it with

#if !defined(MINGW) ... #endif

comment:6 Changed 8 years ago by Danil Ilinykh <woodroof@…>

Just comment out lines 57-65 in file /libs/thread/src/win32/tss_pe.cpp (this is for boost 1.44) and all works fine.

comment:7 in reply to:  6 Changed 8 years ago by tristen_e@…

This is also an issue in 1.41 (and therefore most likely any version onwards.)

I've commented it out (lines 69-77 in v1.41) as suggested by Danil (thank you Sir!) Probably wrapping that bit of code with some kind of #if #endif would be the best solution as suggested by anonymous.

I've recompiled and everything seems OK - for those of you wondering what exactly what code it is that requires commenting in file /libs/thread/src/win32/tss_pe.cpp, it's this:

extern "C" const IMAGE_TLS_DIRECTORY32 _tls_used __attribute__ ((section(".rdata$T"))) =
        (DWORD) &__tls_start__,
        (DWORD) &__tls_end__,
        (DWORD) &__tls_index__,
        (DWORD) (&__crt_xl_start__+1),
        (DWORD) 0,
        (DWORD) 0

comment:8 Changed 8 years ago by Bryce Lelbach

Cc: Bryce Lelbach added
Milestone: Boost 1.43.0Boost-1.45.0
Severity: ProblemShowstopper

Replying to pluto@…:

i'm trying to build my application for mingw
with recent gcc-4.5 cross-compiler but the linker reports an error:

tss_pe.cpp:(.rdata$T+0x0): multiple definition of `__tls_used'
(.tls+0x0): first defined here

Kai Tietz (the mingw maintainer) tolds me that boost needs correction in this area.
here's the link to mingw implementation:


The above is from a from duplicate ticket; information may be relevant

This is not the same as #3847; that ticket claims that this occurs on a broader set of compilers.

comment:9 Changed 8 years ago by Anthony Williams

Resolution: fixed
Status: newclosed

Fixed on trunk, revision 66140

comment:10 Changed 8 years ago by Jim Bell <jim@…>

Could someone shepherd this to the release branch? Thanks.

comment:11 Changed 7 years ago by viboes

It seems this has been merged in #72431

comment:12 Changed 7 years ago by anonymous

Still doesn't work for me :-(

comment:13 Changed 7 years ago by anonymous

Milestone: Boost 1.45.0To Be Determined
Resolution: fixed
Status: closedreopened
Version: Boost 1.44.0Boost 1.49.0

boost 1.49 have this:

#if defined(__MINGW64__) || (__MINGW32_MAJOR_VERSION >3) ||             \

but mingw64 doesn't define


when compiling x86 target. I've changed it to:

#if defined(__MINGW64__) || (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION >3) ||             \

and it solve problem

comment:14 Changed 6 years ago by viboes

Owner: changed from Anthony Williams to viboes
Status: reopenednew

Thanks for the info. I will apply it soon.

comment:15 Changed 6 years ago by viboes

Milestone: To Be DeterminedBoost 1.51.0
Status: newassigned

Committed in trunk [79334]

comment:16 Changed 6 years ago by viboes

Resolution: fixed
Status: assignedclosed

Committed revision [79373].

Note: See TracTickets for help on using tickets.