J'essaie de compiler gcc 4.5.1 pour cygwin avec la prise en charge des threads C++ 0x. Cependant, le gcc résultant ne reconnaît pas l'option -pthread.gcc 4.5.1 Configurer les options pour la prise en charge des threads C++ 0x
Ma commande configure est:
./configure --enable-bootstrap --enable-shared --enable-shared-libgcc
--with-gnu-ld --enable-languages=c,c++ --enable-libgomp
--enable-libssp --enable-threads=posix --with-__thread
L'exemple de programme est:
#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;
}
Je compile un programme C++ en utilisant
$ 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
Ma question est de savoir comment dois-je configurer gcc ?
Etes-vous sûr que vous utilisez et comprendre correctement GCC? Je ne sais pas beaucoup à ce sujet, mais plusieurs choses semblent mal. – leppie
Oui, j'aurais dû utiliser g ++. Mais ça ne marche pas encore. – Salil