【问题标题】:program.exe: Native' has exited with code 255 (0xff)program.exe: Native' 已退出,代码为 255 (0xff)
【发布时间】: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


【解决方案1】:

在我看来,这是 CRT 之间的经典组合:

  1. boost 库与静态调试 CRT 链接(使用所谓的 /MD 开关)
  2. 您的应用程序与静态发布 CRT 相关联(使用所谓的 /MT 开关)

请尝试使用此配方重新编译 boost 库

bjam toolset=msvc-10.0 variant=release threading=multi link=static runtime-link=static

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-26
    • 1970-01-01
    • 2014-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多