我試圖安裝的cygwin編譯一個64位的Windows 7機器上下面的程序和 gcc編譯器更新到4.7.3:cygwin上的gcc 4.7.3支持C++ 11併發功能嗎?
#include <vector>
#include <thread>
#include <mutex>
using namespace std;
std::mutex flemutex;
std::mutex arrmutex;
main() {
thread t;
}
在用下面的命令編譯:
gcc -std=c++11 -o file.o -c file.cpp
我收到以下錯誤:
file.cpp:12:1: error: ‘mutex’ in namespace ‘std’ does not name a type
file.cpp:13:1: error: ‘mutex’ in namespace ‘std’ does not name a type
file.cpp: In function ‘int main()’:
file.cpp:39:3: error: ‘thread’ is not a member of ‘std’
file.cpp:39:15: error: expected ‘;’ before ‘t’
有誰知道怎麼回事?
謝謝!
(1)您是否嘗試將'-lpthread'添加到gcc的命令行? (2)你可以下載MinGW,它不需要cygwin並且可以使用線程「from the box」 – borisbn 2013-05-11 13:11:59
我嘗試在命令行中添加-lpthread,但它不起作用。無論如何,我只是在這裏編譯,沒有鏈接,所以不應該有任何影響,對吧?另外,我希望這可以在cygwin上運行,並且不必在我的機器上安裝MinGW。兩者能否在同一臺機器上和平共處? – user2358643 2013-05-11 13:44:39
簡單 - 更新cygwin和gcc。 – ikh 2014-04-07 11:26:53