PDA

View Full Version : [SOLVED] C++11 threading.



simon5
October 24th, 2013, 11:24 PM
Yep. Moving 'Buntu 13.10 has been nothing short of disastrous (http://ubuntuforums.org/showthread.php?t=2183314). Another thing I've found to be working improperly is threading.
Consider this simple piece of code:

#include <iostream>
#include <thread>
int main()
{
std::thread t ([]()
{
std::cout << "Hello, World!";
});
t.join();
return 0;
}
Compiled with:
g++ main.cpp -o main -pthread -std=c++11
That, on 13.10, throws an exception:

terminate called after throwing an instance of 'std::system_error' what(): Enable multithreading to use std::thread: Operation not permitted
Aborted (core dumped)

... and executes just fine on 13.04. The compiler used in both cases is GCC 4.8.1.
Compiled, and linked against pthread, the same way in both cases.

What's the matter with you, 13.10? What am I doing wrong?

Vaphell
October 24th, 2013, 11:50 PM
apparently bugzored g++
if you check the result with ldd there is no pthread to be seen

workaround: slap -Wl,--no-as-needed at the end
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1228201

simon5
October 25th, 2013, 12:18 AM
apparently bugzored g++
if you check the result with ldd there is no pthread to be seen

workaround: slap -Wl,--no-as-needed at the end
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1228201

Bah. Thank you. I should seriously improve my search-fu.