Esta no es una pregunta duplicada, porque las soluciones presentadas no funcionan en mi compilador. Estoy tratando de compilar y ejecutar el siguiente ejemplo de esta pregunta .
#include <thread> #include <iostream> int main(int, char **){ std::thread tt([](){ std::cout<<"Thread!"<<std::endl; }); tt.join(); }He intentado usar las soluciones presentadas tanto en la pregunta original como en la respuesta aceptada a este duplicado . Sin embargo, aunque probé todas las combinaciones enumeradas, y en particular probé
g++ main.cpp -o main.out -pthread -std=c++11Cuando ejecuto el ejecutable resultante, todavía obtengo
terminate called after throwing an instance of 'std::system_error' what(): Enable multithreading to use std::thread: Operation not permitted Aborted (core dumped) Aquí está la salida de g++ --version .
g++ (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 Copyright (C) 2013 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. ¿Hay un orden diferente o un conjunto de comandos que necesito usar para g++ 4.8.1 ?