Hi, I'm trying to use the boost::thread library in an own dll with Visual Studio 2003. I'm using boost 1.36.0 and built it myself with bjam according to http://www.boost.org/doc/libs/1_36_0/more/getting_started/windows.html First I tested with a simple example, that I've found somewhere in the documentation: struct thread_alarm { thread_alarm(int secs) : m_secs(secs) { } void operator()() { boost::xtime xt; boost::xtime_get(&xt, boost::TIME_UTC); xt.sec += m_secs; // boost::this_thread::sleep(xt); } int m_secs; }; boost::thread thrd(thread_alarm(1)); This code runs and compiles fine. I can add a loop and some couts in the operator() for example and get the output parallel to my application. But when I uncomment the line boost::this_thread::sleep(xt);, I get the following linker error: error LNK2019: unresolved external symbol "bool __stdcall boost::this_thread::interruptible_wait(void *,struct boost::detail::timeout)" (?interruptible_wait@this_thread@boost@@YG_NPAXUtimeout@detail@2@@Z) referenced in function "void __stdcall boost::this_thread::interruptible_wait(class boost::posix_time::ptime const &)" (?interruptible_wait@this_thread@boost@@YGXABVptime@posix_time@2@@Z) The same occurs for other thread methods like yield(). I assume there's a problem with the calling convention, but using something other than __stdcall is not an option for me, since I have to comply with a given specification. I didn't find any information about calling conventions in the boost documentation. Is there a solution for this, or does the boost::thread library require the __cdecl calling convention? Regards, Marc
"Marc Riese"
I'm trying to use the boost::thread library in an own dll with Visual Studio 2003. I'm using boost 1.36.0 and built it myself with bjam according to http://www.boost.org/doc/libs/1_36_0/more/getting_started/windows.html First I tested with a simple example, that I've found somewhere in the documentation:
struct thread_alarm { thread_alarm(int secs) : m_secs(secs) { } void operator()() { boost::xtime xt; boost::xtime_get(&xt, boost::TIME_UTC); xt.sec += m_secs; // boost::this_thread::sleep(xt); }
int m_secs; }; boost::thread thrd(thread_alarm(1));
This code runs and compiles fine. I can add a loop and some couts in the operator() for example and get the output parallel to my application.
But when I uncomment the line boost::this_thread::sleep(xt);, I get the following linker error:
error LNK2019: unresolved external symbol "bool __stdcall boost::this_thread::interruptible_wait(void *,struct boost::detail::timeout)" (?interruptible_wait@this_thread@boost@@YG_NPAXUtimeout@detail@2@@Z) referenced in function "void __stdcall boost::this_thread::interruptible_wait(class boost::posix_time::ptime const &)" (?interruptible_wait@this_thread@boost@@YGXABVptime@posix_time@2@@Z)
The same occurs for other thread methods like yield().
I assume there's a problem with the calling convention, but using something other than __stdcall is not an option for me, since I have to comply with a given specification.
I didn't find any information about calling conventions in the boost documentation. Is there a solution for this, or does the boost::thread library require the __cdecl calling convention?
The thread library must be built with the same calling convention as the rest of the application, since the calling conventions are not specified explicitly on each function. There's an outstanding trac ticket for fixing this. Anthony -- Anthony Williams | Just Software Solutions Ltd Custom Software Development | http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL
participants (2)
-
Anthony Williams
-
Marc Riese