提升互斥C ++ / CLI问题 [英] boost mutex C++/CLI problems
问题描述
我正在开发在Visual Studio 2008中C#为64位,我想用就用它使用升压库。所以,我在C ++ / CLI写的包装。我管理的目标,我得到的错误
I'm developing in Visual Studio 2008 C# for 64bit and I want to use to use a library which uses boost. So I wrote a wrapper in C++/CLI. I managed to target the error I get to
#include <boost/thread/mutex.hpp>.
如果我有我的任何C文件++ / CLI的包装,其本身包括&LT;升压/线程/ mutex.hpp&GT;
或者,如果我直接在包装包括它我得到一个System.AccessViolationException尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
If I include any file in my C++/CLI wrapper that by itself includes <boost/thread/mutex.hpp>
or if I include it directly in the wrapper I get a "System.AccessViolationException" "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
我是非常小心的建筑家居64位,所以我怀疑的问题是存在的。当我在使用相同的库在64位普通C ++一切工作正常。我走了过来一对夫妇的帖子,人们似乎有类似的问题,提升线程,但没有一个解决方案,我找到工作。有没有人有一个想法?
I was very carefull in building everything for 64bit so I doubt that the problems is there. When I use the same library in 64 bit in "plain" C++ everything works fine. I came over a couple of posts where people seem to have similar problems with boost threads but none of the solutions I found worked. Does anyone have an idea?
推荐答案
问题是,boost.thread使用了一些的#pragma节
指令时不带内置不兼容/然后CLR静态链接到使用/ CLR code。
The problem is that boost.thread uses some #pragma section
directives that are incompatible when built without /clr then statically linked to code that uses /clr.
我听说重建boost.thread使用/ clr(即通过 CXXFLAGS =/ CLR
调用的bjam时)解决了问题,但我的避风港'牛逼试了一下个人。
I've heard that rebuilding boost.thread with /clr (i.e., pass cxxflags="/clr"
when invoking bjam) fixes the issue, but I haven't tried it personally.
我认为动态链接到boost.thread(而不是静态的,这是默认的VC ++;#定义BOOST_THREAD_DYN_LINK <$ C C $>包括任何刺激头前)应太,但同样,我还没有尝试过。
I assume that dynamically linking to boost.thread (rather than statically, which is the default for VC++; #define BOOST_THREAD_DYN_LINK
before including any boost headers) should work too, but again, I haven't tried it.
如果还是不行,请尝试使用Google的升压一些组合
线程
CLR
TLS
;你应该找到关于它的boost邮件列表上相当多的职位,因为这是一个旧的问题。
If that doesn't work, try googling for some combination of boost
thread
clr
tls
; you should find quite a few posts on the boost mailing list about it, as this is an old problem.
修改:作为评论<一个href="http://blogs.msdn.com/b/vcblog/archive/2015/04/29/c-11-14-17-features-in-vs-2015-rc.aspx?PageIndex=3#comments"相对=nofollow>这里通过拉曼夏尔马(微软高级PM),甚至的std ::互斥
不支持使用/ clr,所以它的没有真正的惊喜是boost.thread的互斥实现是没有。
EDIT: As commented here by Raman Sharma (a senior PM at Microsoft), even std::mutex
isn't supported with /clr, so it's no real surprise that boost.thread's mutex implementation isn't either.
这篇关于提升互斥C ++ / CLI问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!