(C++) Operation not permitted
February 24, 2017 · View on GitHub
(C++) Operation not permitted
Operation not permitted is a runtime error.
- Download the Qt Creator project 'CppRuntimeErrorOperationNotPermitted' with the error (zip)
- Download the Qt Creator project 'CppRuntimeErrorOperationNotPermitted' with the error fixed (zip)
Full error message
terminate called after throwing an instance of 'std::system_error' what(): Operation not permitted
Code causing the error
#include <iostream> #include <thread> int main() { std::thread t( [] { std::cout<<"Hello world\n"; } ); t.join(); }
With Qt Creator project file:
TEMPLATE = app CONFIG += console CONFIG -= qt QMAKE_CXXFLAGS += -std=c++11 SOURCES += main.cpp
Solution
Add the following line to the Qt Creator project file:
LIBS += -lpthread
Technical facts
Operating system(s) or programming environment(s)
Lubuntu 12.10 (quantal)
Qt Creator 2.5.2
- G++ 4.7.2
Libraries used:
STL: GNU ISO C++ Library, version
4.7.2