Visual Studio 2015 c ++ / CLI Boost ::线程 [英] Visual Studio 2015 c++/CLI boost::thread

查看:112
本文介绍了Visual Studio 2015 c ++ / CLI Boost ::线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有Visual Studio版本都存在此问题,但是在VS 2015中,老把戏似乎不再起作用。

This issue has been around for all Visual Studio versions, but in VS 2015 the "old tricks" don't seem to work anymore.

这就是我的目的尝试过:

This is what I have tried:

将boost headers路径添加到其他包含目录

add boost headers path to Additional Include Directories

add #include boost / thread。 cpp中的 hpp

add #include "boost/thread.hpp" in the cpp

添加以下预处理程序定义(BOOST_USE_WINDOWS_H; BOOST_ALL_NO_LIB; BOOST_ALL_DYN_LINK)

add the following preprocessor definitions (BOOST_USE_WINDOWS_H;BOOST_ALL_NO_LIB;BOOST_ALL_DYN_LINK)

添加链接器依赖项以增强线程和系统库

add linker dependencies to boost thread and system libs

构建小型测试应用程序可编译并与VS链接2013和2015。但是启动VS 2015中内置的应用程序时,该应用程序崩溃:

Building the small test application compiles and links with both VS 2013 and 2015. But when starting the application built in VS 2015, the app crashes:

在TestCLRForms.exe中的0x0000000077C3EB18(ntdll.dll)处引发异常:0xC0000005:访问冲突读取位置0xFFFFFFFFFFFFFFFFFF。

Exception thrown at 0x0000000077C3EB18 (ntdll.dll) in TestCLRForms.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

这是调用堆栈:

ntdll.dll!0000000077c3eb18()    Unknown
KernelBase.dll!000007fefdcd304a()   Unknown
ucrtbased.dll!000007fee02bdeb1()    Unknown
ucrtbased.dll!000007fee02bf9d7()    Unknown
ucrtbased.dll!000007fee02c0438()    Unknown
ucrtbased.dll!000007fee02bfb79()    Unknown
ucrtbased.dll!000007fee02e981d()    Unknown
ucrtbased.dll!000007fee02e9545()    Unknown
ucrtbased.dll!000007fee02e962c()    Unknown
ucrtbased.dll!000007fee02e9d6f()    Unknown
TestCLRForms.exe!_onexit(int(*)() function=0x000000013f627b50) Line 268 C++
TestCLRForms.exe!atexit(void(*)() function=0x000000013f627b50) Line 276 C++
TestCLRForms.exe!__scrt_initialize_thread_safe_statics() Line 109   C++
[Managed to Native Transition]  
TestCLRForms.exe!_initterm_e(int (__cdecl*)()* pfbegin=0x00000000001ad680, int (__cdecl*)()* pfend=0x00000000001ad688) Line 69  C++
TestCLRForms.exe!<CrtImplementationDetails>::LanguageSupport::InitializeNative() Line 355   C++
TestCLRForms.exe!<CrtImplementationDetails>::LanguageSupport::_Initialize() Line 598    C++
TestCLRForms.exe!<CrtImplementationDetails>::LanguageSupport::Initialize() Line 805 C++
TestCLRForms.exe!.cctor() Line 856  C++
[Native to Managed Transition]  
[Managed to Native Transition]  
[Native to Managed Transition]  
mscoreei.dll!000007fef8107fd5() Unknown
mscoree.dll!000007fef81a5b21()  Unknown
kernel32.dll!0000000077b159cd() Unknown
ntdll.dll!0000000077c4a2e1()    Unknown

仅针对x64进行了测试。

Tested only for x64.

有人有想法吗?谢谢

推荐答案

我找到了一种解决方法(至少部分解决了上述问题)。我将其发布在这里,其他人可能会觉得有用。

I found a workaround that (at least partially) solves the above problem. I post it here, someone else might find it useful.

如果Linker / System中的SubSystem选项设置为Console,Linker / Advanced中的Entry Point留为空白(重要!),则不会发生崩溃,并且该应用可以正常运行。这种解决方法的缺点是会与GUI应用程序一起打开控制台窗口。

If the SubSystem option in Linker/System is set to Console and the Entry Point in Linker/Advanced is left blank (important!), then the crash doesn't occur and the app works. The disadvantage of this workaround is that a console window is opened alongside with the GUI application.

我个人可以接受此操作,因为我的应用程序只是一个测试程序,但是

I personally can live with this, because my application is just a test program, but for others it might not be acceptable.

如果有人可以找到更好的解决方案,原始问题仍然悬而未决。

The original question remains open if someone can find a better solution.

这篇关于Visual Studio 2015 c ++ / CLI Boost ::线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆