2
votes

My problem is: If I compile and link my multithread application with c++11 threads on my own with my own makefile with GCC compiler (I work on Ubuntu), all work properly. Program run correctly.

(I use -pthreads and -std=c++11 and all work great)

But if I want create project in IDE (netbeans or QT with standard set on c++11) and compile my source code with makefile generated by IDE (simply click button "BUILD"), while running executive file I receive:

terminate called after throwing an instance of 'std::system_error' what(): Enable multithreading to use std::thread: Operation not permitted

I know that was answer about this error, but they was related to g++ compiler. My compiler work correctly, but i have problem with IDE. PS: In Netbeans I add -pthread to compile flags

1
It seems you're not really adding -pthread to the command line. Get Netbeans to print the command line it is invoking g++ with.Praetorian
in the output g++ -pthread -c -g -std=c++11 -MMD -MP -MF "build/Debug/GNU-Linux-x86/main.o.d" -o build/Debug/GNU-Linux-x86/main.o main.cpp mkdir -p dist/Debug/GNU-Linux-x86 I reall g++ -pthread -o dist/Debug/GNU-Linux-x86/123 build/Debug/GNU-Linux-x86/main.ofingolfin
I think that you can find useful this conversation: forums.netbeans.org/ntopic9511.htmlAlessandro Suglia
I add -pthread in "Additional Option"fingolfin
Praetorian, Alessandro - thank you. I do it again and all work great.fingolfin

1 Answers

2
votes

Project properties->build->c++ compiler->compilation lines->Additional Option click this small button to the right of "Additional Option" and add "-pthread"