program.exe: Native' has exited with code 255 (0xff)

血红的双手。 提交于 2019-12-12 20:04:11

问题


I am using boost threads, and everything works perfectly when compiling with /MD but I really prefer compiling with /MT instead

The problem I then get is program.exe: Native' has exited with code 255 (0xff).

This happens on this line:

thread_1 = thread(testThread,test);

after digging down deeper, I realised the problem is the fact that _crtheap equals to 0, ie: it's not initialized.

as seen in 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) */
    }

so now I know what the problem is, but for the life of me I can't figure out how to fix it

boost is built like this (for this particular compile, which gives the .lib's msvc++ asks for)

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

回答1:


Seems to me as a classic mix between CRTs hiccup :

  1. The boost library is linked against static debug CRT (using the so called /MD switch)
  2. Your application is linked against static release CRT (using the so called /MT switch)

Please try recompiling the boost library using this recipe

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


来源:https://stackoverflow.com/questions/9605186/program-exe-native-has-exited-with-code-255-0xff

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!