Boost logo

Boost :

Subject: Re: [boost] [threads] Problem static linking with boost.thread during cross-compilation
From: Victor Leschuk (vleschuk_at_[hidden])
Date: 2011-09-28 12:47:10


Thanks for advice. The situation has changed but now it reports number of
multiple definitions of destructors:

$ x86_64-w64-mingw32-g++ -DBOOST_THREAD_USE_LIB=1 -Wall test_boost.cpp -I
./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

On Wed, Sep 28, 2011 at 4:26 PM, TONGARI <tongari95_at_[hidden]> wrote:

> 2011/9/28 Victor Leschuk <vleschuk_at_[hidden]>
>
> > Hello all,
> >
> > I have just met the following problem: 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.
> >
> > What could be the cause of the problem and where to look? Does it worse
> > posting a defect in bug-tracker?
> >
>
> Try to compile with -DBOOST_THREAD_USE_LIB=1
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk