我遇到了一点奇怪的行为,当我尝试编译使用多线程在CodeLite任何程序。C++ CodeLite启用多线程?
我得到的错误:
terminate called after throwing an instance of 'std::system_error'
what(): Enable multithreading to use std::thread: Operation not premitted.
一些快速google搜索,我发现我不得不添加“-pthread”编译器选项之后。
注意:CodeLite把-l在图书馆前面,所以它并使用-lpthread
我干净后,重建项目,我仍然得到错误,但。据我可以告诉构建日志看起来不错?
而真正令人沮丧的说到,当我通过命令行手动编译它,它工作得很好。
我已经搜查,但没有解决方案,似乎为我工作?也许我错过了某个地方的某个步骤?
这里是我的测试代码。 我也应该注意到我使用Ubuntu14.04和CodeLite 9.1.0
#include <iostream>
#include <string>
#include <thread>
void test()
{
std::cout << " Look it works! \n";
}
void int main(int argc, char** argv)
{
std::thread thrd_1 = std::thread(test);
thrd_1.join();
return 0;
}
任何帮助将不胜感激!
您正在链接到IDE中的pthread?我使用:'-pthread -lpthread轮候册, - 无作为,needed'。您的命令行有'-lpthread'但你对你的IDE的截屏不显示连接选项。 – Brandon
@Brandon啊,对不起,我也在链接'-lpthread'我会做一个快速编辑。我已经尝试过'-Wl, - 不需要'作为编译器选项了?也许我把它放在错误的地方? – Dusty