0

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
letsBeePolite
  • 2,183
  • 1
  • 22
  • 37
  • did you join your thread? I'm not able to see that in your code... – codekiddy Mar 09 '15 at 23:38
  • @codekiddy: I did join and on terminal the correct is generated..... – letsBeePolite Mar 10 '15 at 00:46
  • See if this helps; http://stackoverflow.com/questions/19463602/compiling-multithread-code-with-g – glank Mar 10 '15 at 02:16
  • @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 Mar 11 '15 at 15:03
  • @MikeKinghan : I have uploaded a screenshot for the build log, please do have a look – letsBeePolite Mar 11 '15 at 15:28
  • Please replace the screenshot by text. There's roughly 95% useless information in the pictures and they are fairly small and hard to read. – stefan Mar 11 '15 at 15:31
  • The build Log:::: g++ -Wall -fexceptions -pthread -std=c++11 -c /home/subhadeep/Desktop/TestStack/StackOverflow/main.cpp -o obj/Debug/main.o g++ -o bin/Debug/StackOverflow obj/Debug/main.o Output file is bin/Debug/StackOverflow with size 49.78 KB Process terminated with status 0 (0 minute(s), 0 second(s)) 0 error(s), 0 warning(s) (0 minute(s), 0 second(s)) – letsBeePolite Mar 11 '15 at 15:33

2 Answers2

0

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

Englund
  • 1,067
  • 7
  • 13
  • The error still persists I posted the screenshot, please have a look and let me know if there is anything that you can help me with – letsBeePolite Mar 09 '15 at 23:31
0

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

Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182