0
votes

The Build logenter image description hereenter image description hereI have code which uses multithread ability of C++11. I am able to execute the code in the terminal using the commenter image description hereand:

g++ main.cpp -o main -pthread -std=c++11

But I am unable to execute the same code from the CodeBlocks. Whenever I attempt to do it, it throws the error : terminate called after throwing an instance of std::system_error what(): Enable multithreading....

I know that Codeblocks, is building the code without '-pthread' in it, but I don't know to add that in CodeBlocks.

enter image description here

2
did you join your thread? I'm not able to see that in your code... - codekiddy
@codekiddy: I did join and on terminal the correct is generated..... - letsBeePolite
@skn Please post the build log of your build (from clean). You'll find it under the Build log (not Build messages) tab. - Mike Kinghan
@MikeKinghan : I have uploaded a screenshot for the build log, please do have a look - letsBeePolite

2 Answers

0
votes

Remove -pthread from Build options -> Compiler settings -> Other options and add it to Build options -> Linker settings -> Other options, then rebuild.

0
votes

To add the compiler flag -pthread: Go to Project -> Build Options -> Compiler Settings tab -> Other Options and enter -pthread