2

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
zeta
  • 1,113
  • 3
  • 15
  • 24

1 Answers1

0

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
Shmil The Cat
  • 4,548
  • 2
  • 28
  • 37