【发布时间】:2012-03-25 04:47:36
【问题描述】:
我正在使用 boost 线程,使用 /MD 编译时一切正常,但我更喜欢使用 /MT 编译
然后我得到的问题是 program.exe: Native' has exited with code 255 (0xff).
这发生在这一行:
thread_1 = 线程(testThread,test);
在深入挖掘之后,我意识到问题在于_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
【问题讨论】:
-
拜托,你能提供一个完整的例子吗?
标签: c++ visual-c++ boost boost-thread msvcrt