[英]XCode std::thread C++
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. 对于学校的小项目,我需要创建一个简单的客户端/服务器构造,它将在路由器上运行(使用openWRT),我正在尝试使用此应用程序中的线程做一些事情。
My C++ skills are very limited, so I found this on the internet as an basic example. 我的C ++技能非常有限,所以我在互联网上发现这是一个基本的例子。
#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: 当我尝试在Xcode(4.5.2)中运行它时,我收到以下错误:
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. 在XCode中使用G ++而不是LLVM。 Don't forget to link thread libs (-lpthread - or -pthread, -lrt) in compiler build settings.
不要忘记在编译器构建设置中链接线程库(-lpthread - 或-pthread,-lrt)。 And count with the differences of thread behaviour across Win/Mac/Linux OS (despite it's POSIX)
并计算Win / Mac / Linux操作系统中线程行为的差异(尽管它是POSIX)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.