我遇到了一點奇怪的行爲,當我嘗試編譯使用多線程在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