Answer the question
In order to leave comments, you need to log in
Can't find std::threads. What's wrong?
C::B does not find thread. In the compilation settings (both project>>build options and settings>>compiler) I specified the use of C++14 (threads are allowed from C++11).
Code, for example, is:
#include <thread>
using namespace std;
void doIt(){
//do nothing
}
int main(){
thread t(doIt);
t.detach();
return 0;
}
Answer the question
In order to leave comments, you need to log in
Can't find std::threads. What's wrong?
$ cat > thr.cpp
#include <thread>
using namespace std;
void doIt(){
//do nothing
}
int main(){
thread t(doIt);
t.detach();
return 0;
}
$ g++ -std=c++11 thr.cpp -o thr
/tmp/ccVyziLM.o: In function `std::thread::thread<void (&)()>(void (&)())':
thr.cpp:(.text._ZNSt6threadC2IRFvvEJEEEOT_DpOT0_[_ZNSt6threadC5IRFvvEJEEEOT_DpOT0_]+0x20): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
$ g++ -std=c++11 thr.cpp -pthread -o thr
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question