Using Visual Studio 2008 and Boost Libraries 1.46.1 I want to compile and link the following with the /CLR flag:
#include <boost/thread/thread.hpp>
void run() {}
int main(int argc, char *argv[])
{
boost::thread t(run);
}
The first error is about a forward-declared dummy-struct in boost::thread. This post works around this by declaring:
namespace boost {
struct thread::dummy {};
}
Sure, I now can compile, but then I get the linker warning
Warning 1 warning LNK4248: unresolved typeref token (0100001F) for 'boost.detail.win32._SECURITY_ATTRIBUTES'; image may not run
Running the application results in
The application was unable to start correctly (0xc000007b).
None of the suggestions in the previously mentioned forum thread works for me. I have built a static version of the Boost Threads lib, and it runs fine without the /CLR flag. Debug/Release makes no difference. I'm running under Win7 32-bit.
Any hints?
Thread enables the use of multiple threads of execution with shared data in portable C++ code. The Boost. Thread library was originally written and designed by William E.
Interrupting a Thread A running thread can be interrupted by calling the interrupt() member function on the corresponding boost::thread object. If the thread doesn't have a boost::thread object (e.g the initial thread of the application), then it cannot be interrupted.
Since boost is mainly just a wrapper around pthreads (on posix platforms) it helps to know what is going on underneath. In attempting to be generic, boost leaves the platform specific functionality unwrapped. In order to get to it you need to use the native_handle() calls.
I've already run into this problem, i don't remember where i got this but one workaround is declare "boost.detail.win32._SECURITY_ATTRIBUTES" after including all the boost headers like so.
namespace boost {
namespace detail {
namespace win32 {
struct _SECURITY_ATTRIBUTES: public ::_SECURITY_ATTRIBUTES {};
};
};
};
Remove the namespaces if you want everyone to see it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With