Quais são as opções de link corretas para usar std :: thread no GCC no Linu
Oi estou tentando usarstd::thread
com G ++. Aqui está o meu código de teste
#include <thread>
#include <iostream>
int main(int, char **){
std::thread tt([](){ std::cout<<"Thread!"<<std::endl; });
tt.join();
}
Compila, mas quando tento executá-lo, o resultado é:
terminate called after throwing an instance of 'std::system_error'
what(): Operation not permitted
Aborted
inha versão do compilador:
$ g++ --version
g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
O que há de errado com meu código de teste?
UPDATE: Eu uso a seguinte linha de comando para compilar e executar meu códig
$ g++ -std=c++0x test.cpp
$ ./a.out
e eu tentei
$ g++ -std=c++0x -lpthread test.cpp
$ ./a.out
ainda o mesmo
UPDATE: o seguinte comando de compilação funcion
$ g++ -std=c++0x test.cpp -lpthread
$ ./a.out
Thread!