|
Boost : |
Subject: [boost] [threads] Problem static linking with boost.thread during cross-compilation
From: Victor Leschuk (vleschuk_at_[hidden])
Date: 2011-09-28 07:51:13
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?
Thanks!
-- Victor
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk