這是來自ubuntu 13.10和g ++ 4.8的一個bug,所以我關閉了這個問題。cpp線程程序無法運行-fprofile-arcs
within -Wl,--no-as-needed.
我頭上有什麼問題。 我得到了一些類似的代碼
#include <iostream>
#include <thread>
int main(int argc, char* argv[])
{
{
std::thread t1([&]{ std::cout << "hello " << std::endl; });
t1.join();
}
return 0;
}
,這裏是我的編譯命令:
g++ -std=c++0x -lpthread test.cpp
PS:我已經改變我的鏈接順序爲所有種類的順序。
它適用於G ++ 4.7和Ubuntu 13.04 但它在G ++ 4.8.1拋出SYSTEM_ERROR和Ubuntu 12.10
,直到我用-fprofile弧它工作得很好編譯。
只是波紋管:
g++ test.cpp -std=c++0x -fprofile-arcs -pthread
a.out
hello
g++ test.cpp -std=c++0x -pthread
a.out
terminate called after throwing an instance of 'std::system_error'
什麼():啓用多線程使用std ::線程:操作不允許
它在編譯或鏈接失敗嗎? – tristan
假設鏈接,導致運行時發生錯誤 – sinsaychen
編譯爲'g ++ -std = C++ 0x test.cpp -lpthread'時正常工作。當編譯爲'g ++ -std = C++ 0x -lpthread test.cpp'時拋出「operation not permitted」系統異常。 – Duck