[Boost-bugs] [Boost C++ Libraries] #5964: Linkage fails with cross-compiled boost.thread

Subject: [Boost-bugs] [Boost C++ Libraries] #5964: Linkage fails with cross-compiled boost.thread
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-09-29 20:44:53


#5964: Linkage fails with cross-compiled boost.thread
-------------------------------------+--------------------------------------
 Reporter: anonymous | Owner: anthonyw
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
  Version: Boost Development Trunk | Severity: Problem
 Keywords: |
-------------------------------------+--------------------------------------
 I am cross-compiling boost 1.47
 using

 $ x86_64-w64-mingw32-g++ --version

 x86_64-w64-mingw32-g++ (GCC) 4.5.4 20110822 (prerelease)

 On Linux box with the following command:

 ./b2 -a toolset=gcc target-os=windows threading=multi threadapi=pthread
 runtime-link=static --layout=versioned --build-type=complete install

 user-config.jam contains the following:

 using gcc : mingw : x86_64-w64-mingw32-g++ ;

 After that a linkage failed when building my project. I reproduced it with
 simple test program:

 #include <boost/thread.hpp>
 #include <iostream>

 using namespace std;

 struct test
 {
     void operator()() { cout << "Called" << endl; }
 };

 int main()
 {
     test test_obj;
     boost::thread thr(test_obj);
     thr.join();
 }

 The output looks like

 $ x86_64-w64-mingw32-g++ -Wall test_boost.cpp -I
 ./3rdparty/boost/include/boost-1_47 -L ./3rdparty/boost/lib
 -lboost_thread-mgw-mt-s-1_47 -o test_boost.exe
 In file included from
 ./3rdparty/boost/include/boost-
 1_47/boost/thread/win32/thread_data.hpp:12:0,
                  from
 ./3rdparty/boost/include/boost-1_47/boost/thread/thread.hpp:15,
                  from ./3rdparty/boost/include/boost-
 1_47/boost/thread.hpp:13,
                  from test_boost.cpp:2:
 ./3rdparty/boost/include/boost-
 1_47/boost/thread/win32/thread_heap_alloc.hpp:59:40:
 warning: inline function ‘void*
 boost::detail::allocate_raw_heap_memory(unsigned int)’ declared as
 dllimport: attribute ignored
 ./3rdparty/boost/include/boost-
 1_47/boost/thread/win32/thread_heap_alloc.hpp:69:39:
 warning: inline function ‘void
 boost::detail::free_raw_heap_memory(void*)’ declared as dllimport:
 attribute ignored
 /tmp/ccSmsBnO.o:test_boost.cpp:(.text+0xde): undefined reference to
 `__imp__ZN5boost6thread4joinEv'
 /tmp/ccSmsBnO.o:test_boost.cpp:(.text+0xfb): undefined reference to
 `__imp__ZN5boost6threadD1Ev'
 /tmp/ccSmsBnO.o:test_boost.cpp:(.text+0x1c3): undefined reference to
 `__imp__ZN5boost6threadD1Ev'
 /tmp/ccSmsBnO.o:test_boost.cpp:(.text$_ZN5boost6threadC1I4testEET_NS_10disable_ifINS_14is_convertibleIRS3_NS_6detail13thread_move_tIS3_EEEEPNS0_5dummyEE4typeE[boost::thread::thread<test>(test,
 boost::disable_if<boost::is_convertible<test&,
 boost::detail::thread_move_t<test> >,
 boost::thread::dummy*>::type)]+0xd5): undefined reference to
 `__imp__ZN5boost6thread12start_threadEv'
 collect2: ld returned 1 exit status

 The same scenario works fine when linking with dynamic libboost_thread.
 Both
 static and dynamic builds work fine for Linux.


 When I add define

 -DBOOST_THREAD_USE_LIB=1

 it results in following:

 ./3rdparty/boost/include/boost-1_47
 ./3rdparty/boost/lib/libboost_thread-mgw-mt-1_47.a
 /home/del/pthreads-w64/pthreads/libpthreadGC2.a -o test_boost.exe
 ./3rdparty/boost/lib/libboost_thread-mgw-mt-1_47.a(thread.o): duplicate
 section `.data$_ZTIN5boost6detail16thread_data_baseE[typeinfo for
 boost::detail::thread_data_base]' has different size
 ./3rdparty/boost/lib/libboost_thread-mgw-mt-
 1_47.a(thread.o):thread.cpp:(.text+0x3a00):
 multiple definition of
 `boost::detail::thread_data_base::~thread_data_base()'
 /tmp/ccROgsoo.o:test_boost.cpp:(.text$_ZN5boost6detail16thread_data_baseD2Ev[boost::detail::thread_data_base::~thread_data_base()]+0x0):
 first defined here
 ./3rdparty/boost/lib/libboost_thread-mgw-mt-
 1_47.a(thread.o):thread.cpp:(.text+0x3a00):
 multiple definition of
 `boost::detail::thread_data_base::~thread_data_base()'
 /tmp/ccROgsoo.o:test_boost.cpp:(.text$_ZN5boost6detail16thread_data_baseD1Ev[boost::detail::thread_data_base::~thread_data_base()]+0x0):
 first defined here
 ./3rdparty/boost/lib/libboost_thread-mgw-mt-
 1_47.a(thread.o):thread.cpp:(.text+0x3d50):
 multiple definition of
 `boost::detail::thread_data_base::~thread_data_base()'
 /tmp/ccROgsoo.o:test_boost.cpp:(.text$_ZN5boost6detail16thread_data_baseD0Ev[boost::detail::thread_data_base::~thread_data_base()]+0x0):
 first defined here
 collect2: ld returned 1 exit status

 I have reproduced it with boost 1.43, 1.46.1, 1.47 and latest (74606)
 revision from svn. Tried two differen mingw-w64 gcc versions: 4.5.4 and
 4.7.0.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5964>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:07 UTC