我正在使用 boost 线程,并且在使用 /MD 编译时一切正常,但我真的更喜欢使用 /MT 编译
然后我遇到的问题是program.exe:Native'已退出,代码为255(0xff)。
这发生在这条线上:
thread_1 = 线程(testThread,测试);
深入挖掘后,我意识到问题是 _crtheap 等于 0,即:它没有初始化。
如 mlock.c 中所示
/*
* Check if CRT is initialized. The check if _crtheap is initialized
* will do the job. More over we had to add this test in initlocks because
* in debug version we don't endup calling lock before calling malloc_base,
* where we check for crtheap.
*/
if (_crtheap == 0) {
_FF_MSGBANNER(); /* write run-time error banner */
_NMSG_WRITE(_RT_CRT_NOTINIT); /* write message */
__crtExitProcess(255); /* normally _exit(255) */
}
所以现在我知道问题是什么,但我一生都不知道如何解决它
boost 是这样构建的(对于这个特定的编译器,它给出了 .lib 的 msvc 要求)
bjam toolset=msvc-10.0 variant=debug threading=multi link=static runtime-link=static
在我看来,这是 CRT 打嗝之间的经典组合:
- boost 库与静态调试 CRT 链接(使用所谓的 /MD 开关)
- 您的应用程序与静态发布 CRT 链接(使用所谓的 /MT 开关)
请尝试使用此配方重新编译 boost 库
bjam toolset=msvc-10.0 variant=release threading=multi link=static runtime-link=static
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)