For a small project for school I need to create a simple client / server construction which will run on a router (with openWRT) and I am trying to do something with threads in this application.
My C++ skills are very limited, so I found this on the internet as an basic example.
#include <thread>
#include <iostream>
void doSomeWork( void )
{
std::cout << "hello from thread..." << std::endl;
return;
}
int main( int argc, char *argv[] )
{
std::thread t( doSomeWork );
t.join();
return 0;
}
When I try to run this in Xcode (4.5.2) I get the following error:
Attempt to use an deleted function
And it shows some code of:
__threaad_execute(tuple<_Fp, _Args...>& __t, __tuple_indices<_Indices...>)
{
__invoke(_VSTD::move(_VSTD::get<0>(__t)), _VSTD::move(_VSTD::get<_Indices>(__t))...);
}
I think I need to do something with 'build settings' or 'link library' or something? But I am not quite sure what to do exactly. I thought I might need to set the following settings (which i found here)
But those settings where already set.
Is there any flag / library or something I am missing?
Use G++ instead of LLVM in XCode. Don't forget to link thread libs (-lpthread - or -pthread, -lrt) in compiler build settings. And count with the differences of thread behaviour across Win/Mac/Linux OS (despite it's POSIX)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With