C ++ Threads, std :: system_error - Operation nicht erlaubt? [Duplikat
Diese Frage hat hier bereits eine Antwort:
Was sind die richtigen Linkoptionen für die Verwendung von std :: thread in GCC unter Linux? 6 answersSo schrieb ich ein Programm zum Testen von Threads auf 64-Bit-Kubuntu-Linux, Version 13.04. Eigentlich habe ich den Code jemand anderem geraubt, der ein Testprogramm geschrieben hat.
#include <cstdlib>
#include <iostream>
#include <thread>
void task1(const std::string msg)
{
std::cout << "task1 says: " << msg << std::endl;
}
int main(int argc, char **argv)
{
std::thread t1(task1, "Hello");
t1.join();
return EXIT_SUCCESS;
}
Ich habe kompiliert mit:
g++ -pthread -std=c++11 -c main.cpp
g++ main.o -o main.out
Dann lief:
./main.out
Außerdem wird main.out, wenn ich 'ls -l' bin, wie alle ausführbaren Dateien im grünen Text angezeigt, hat aber auch ein Sternchen am Ende seines Namens. Warum ist das
Zurück zum vorliegenden Problem: Beim Ausführen von main.out ist ein Fehler aufgetreten, der besagt:
terminate called after throwing an instance of 'std::system_error'
what(): Operation not permitted
Aborted (core dumped)
Hat jemand eine Idee, wie man das behebt?