I have searched through forums here, but nothing helped to the end in my case. I'm trying to write and compile some C++ multithreading code in Code::Blocks 13.12, for now the only code I have is:
#include <iostream>
#include <thread>
void cpp11()
{
std::cout<<"C++11 MULTITHREADING\n";
}
int main()
{
std::thread t(cpp11);
t.join();
}
Initially I could not compile and run that code (both in Code::Blocks and Terminal) because I was getting an error:
Terminate called after throwing an instance of 'std::system_error' what(): Enable multithreading to use std::thread: Operation not permitted.
I found that I'm able to compile and run that code calling g++ in the Terminal like that:
g++ -std=c++11 -pthread main.cpp -o Program
but I cannot set the same in Code::Blocks. I went to Project -> Build options, in the Compiler settings tab I selected Have g++ follow the C++11 ISO C++ language standard [-std=c++11]. In the Compiler settings -> Other options I typed -pthread. In Linker settings -> Other linker options I typed -pthread. It does not work, after I build and run my project in Code::Blocks I get the same error message.
Thank you for any help!