简体   繁体   中英

Boost in Visual Studio 2010 using /clr

I made a series of classes that I wish to incorporate into a Windows Forms application for Visual Studio 2010. Those classes utilize Boost, specifically boost::thread.

With common language runtime support enabled, I receive the following error messages:

1>c:\program files (x86)\boost\boost_1_47\boost\thread\win32\thread_primitives.hpp(314): error C2472: 'boost::detail::win32::interlocked_bit_test_and_set' cannot be generated in managed code: 'Found an intrinsic not supported in managed code'; compile with /clr to generate a mixed image

1>c:\program files (x86)\boost\boost_1_47\boost\thread\win32\basic_timed_mutex.hpp(160): error C2472: 'boost::detail::basic_timed_mutex::unlock' cannot be generated in managed code: 'Found an intrinsic not supported in managed code'; compile with /clr to generate a mixed image

I understand what the message is saying, but I don't know how to work around it. Disabling common language runtime support in the Project Properties creates a ton of other errors, so: how do I incorporate /clr into the Boost library I'm using?

Boost.thread uses some thread local storage calls that don't work if you directly link them with CLR code. In VS2008 the link would succeed but you'd crash on startup -- I suspect this is a symptom of the same problem, VS2010-style. The workaround is to build boost.thread as a DLL instead of linking it statically, and maybe it'll link for you that way...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM