Ticket #4258 (closed Bugs: fixed)

Opened 7 years ago

Last modified 5 years ago

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: wash


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

comment:1 Changed 7 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 7 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 7 years ago by anonymous

Duplicated of #3847?

comment:4 Changed 7 years ago by aszarsha

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

comment:5 Changed 7 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 follow-up: ↓ 7 Changed 7 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 7 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 7 years ago by wash

  • Cc wash added
  • Severity changed from Problem to Showstopper
  • Milestone changed from Boost 1.43.0 to Boost-1.45.0

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 7 years ago by anthonyw

  • Status changed from new to closed
  • Resolution set to fixed

Fixed on trunk, revision 66140

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

Could someone shepherd this to the release branch? Thanks.

comment:11 Changed 5 years ago by viboes

It seems this has been merged in #72431

comment:12 Changed 5 years ago by anonymous

Still doesn't work for me :-(

comment:13 Changed 5 years ago by anonymous

  • Status changed from closed to reopened
  • Version changed from Boost 1.44.0 to Boost 1.49.0
  • Resolution fixed deleted
  • Milestone changed from Boost 1.45.0 to To Be Determined

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 5 years ago by viboes

  • Owner changed from anthonyw to viboes
  • Status changed from reopened to new

Thanks for the info. I will apply it soon.

comment:15 Changed 5 years ago by viboes

  • Status changed from new to assigned
  • Milestone changed from To Be Determined to Boost 1.51.0

Committed in trunk [79334]

comment:16 Changed 5 years ago by viboes

  • Status changed from assigned to closed
  • Resolution set to fixed

Committed revision [79373].


Add a comment

Modify Ticket

Change Properties
<Author field>
as closed
The resolution will be deleted. Next status will be 'reopened'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.