我想爲支持C++ 0x線程的cygwin編譯gcc 4.5.1。 但是,生成的gcc無法識別-pthread選項。gcc 4.5.1 C++ 0x線程支持的配置選項
我的configure命令是:
./configure --enable-bootstrap --enable-shared --enable-shared-libgcc
--with-gnu-ld --enable-languages=c,c++ --enable-libgomp
--enable-libssp --enable-threads=posix --with-__thread
的示例程序是:
#include <iostream>
#include <thread>
using namespace std;
void hello()
{
cout << "Hello Concurrent World!" << endl;
}
int main()
{
cout << "starting" << endl;
thread t(hello);
t.join();
cout << "ending" << endl;
return 0;
}
我編譯使用
$ gcc -Wall -g -std=c++0x -pthread Trial.cpp
gcc: unrecognized option '-pthread'
Trial.cpp: In function `int main()':
Trial.cpp:21:5: error: `thread' was not declared in this scope
Trial.cpp:21:12: error: expected `;' before `t'
Trial.cpp:22:5: error: `t' was not declared in this scope
C++程序我的問題是我應該如何配置GCC ?
你確定你使用的是正確地認識GCC的手冊?我對此不太瞭解,但有幾件事情看起來不對。 – leppie 2010-08-24 05:06:03
是的,我應該使用g ++。但它仍然不起作用。 – Salil 2010-08-25 03:56:31