2

我创建了一系列类,希望将它们合并到 Visual Studio 2010 的 Windows 窗体应用程序中。这些类使用 Boost,特别是 boost::thread。

启用公共语言运行时支持后,我收到以下错误消息:

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

我明白消息在说什么,但我不知道如何解决它。在项目属性中禁用公共语言运行时支持会产生大量其他错误,因此:如何将 /clr 合并到我正在使用的 Boost 库中?

4

1 回答 1

0

Boost.thread 使用了一些线程本地存储调用,如果您直接将它们与 CLR 代码链接起来,这些调用将不起作用。在 VS2008 中,链接会成功,但您会在启动时崩溃——我怀疑这是 VS2010 风格的相同问题的症状。解决方法是将 boost.thread 构建为 DLL 而不是静态链接它,也许它会以这种方式为你链接......

于 2012-06-21T14:01:27.713 回答