我想为支持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