Coding,  Open Source

C++ 11 tip of the day

If you’re working with code using C++11 ‘s use of the <thread> library, and you get this error at runtime:

[code lang=”bash”] terminate called after throwing an instance of ‘std::system_error’
what(): Operation not permitted
zsh: abort ./main

That means you forgot to tell g++ to link to the pthread library when you compiled. Add the flag

[code lang=”bash”] -lpthread [/code]

to your g++ command string, and you should be set to go.

I’ve run into this error a few times already, and I haven’t found a good google search that answers it, so I decided to write this one. Hope it absolves a few head-scratchers out there….


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.