Opened 12 years ago

Closed 10 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 Adelstein Lelbach

Description

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 by Danil Ilinykh <woodroof@…>, 12 years ago

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

comment:2 by Danil Ilinykh <woodroof@…>, 12 years ago

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

comment:3 by anonymous, 12 years ago

Duplicated of #3847?

comment:4 by aszarsha, 12 years ago

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

comment:5 by anonymous, 12 years ago

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 by Danil Ilinykh <woodroof@…>, 12 years ago

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.

in reply to:  6 comment:7 by tristen_e@…, 12 years ago

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 by Bryce Adelstein Lelbach, 12 years ago

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

Replying to pluto@…:

hi,
i'm trying to build my application for mingw http://mingw-w64.sourceforge.net
with recent gcc-4.5 cross-compiler but the linker reports an error:

(...)buildenv/windows/gcc-4.5/32/boost-1.44.0/lib/libboost_thread.a(tss_pe.o):
tss_pe.cpp:(.rdata$T+0x0): multiple definition of `__tls_used'
(...)/i686-pc-mingw32/lib/libmingw32.a(lib32_libmingw32_a-tlssup.o):
(.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:

tlssup.c

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 by Anthony Williams, 12 years ago

Resolution: fixed
Status: newclosed

Fixed on trunk, revision 66140

comment:10 by Jim Bell <jim@…>, 11 years ago

Could someone shepherd this to the release branch? Thanks.

comment:11 by viboes, 11 years ago

It seems this has been merged in #72431

comment:12 by anonymous, 11 years ago

Still doesn't work for me :-(

comment:13 by anonymous, 11 years ago

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) ||             \
    ((__MINGW32_MAJOR_VERSION==3) && (__MINGW32_MINOR_VERSION>=18))

but mingw64 doesn't define

__MINGW64__

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

#if defined(__MINGW64__) || (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION >3) ||             \
    ((__MINGW32_MAJOR_VERSION==3) && (__MINGW32_MINOR_VERSION>=18))

and it solve problem

comment:14 by viboes, 10 years ago

Owner: changed from Anthony Williams to viboes
Status: reopenednew

Thanks for the info. I will apply it soon.

comment:15 by viboes, 10 years ago

Milestone: To Be DeterminedBoost 1.51.0
Status: newassigned

Committed in trunk [79334]

comment:16 by viboes, 10 years ago

Resolution: fixed
Status: assignedclosed

Committed revision [79373].

Note: See TracTickets for help on using tickets.