0

In the simple code below, if I include the boost threading library, the program is terminated on execution, the main function is not even reached.

Everything compiles properly with 0 warning, 0 error.

My environment:

  • Eclipse Kepler
  • boost_1_65_1
  • gcc 6.3.0
  • Mingw (Don't know version, I have the current release on sourceforge)
  • In Project/C/C++ Build/Settings
    • GCC C++ Compiler/Includes: c\boost\boost_1_65_1
    • MinGW C++ Linker/Libraries:
      • Library search path: C:\boost\boost_1_65_1\stage\lib
      • Libraries: llibboost_thread-mgw63-mt-1_65_1 , libboost_system-mgw63-mt-1_65_1 , libboost_chrono-mgw63-1_65_1

Code:

#include <iostream>
#include <boost/thread/thread.hpp>
int main(int argc, char* argv[])
{
std::cout << "StackUnderFlow" << std::endl;
return 0;
}

I have no idea what is the source of the issue, is it:

  • the way I built Boost/Thread
  • how the project is configured
  • ?

The gdb traces shows this error:

058,965 25^error,msg="During startup program exited with code 0xc0000135."
058,965 (gdb) 
058,965 26^error,msg="Can not fetch data now."
058,965 (gdb) 
058,980 27-gdb-exit
058,980 28-data-evaluate-expression $_exitcode
058,996 27^exit
vincedjango
  • 1,022
  • 1
  • 13
  • 24

1 Answers1

0

The code needs to be both compiled and linked with -pthread option. -lpthread linker option is insufficient and unnecessary.

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271