Why do you have to add -pthread option when compiling with the Std thread library?

Asked

Viewed 60 times

3

If in the main.cpp I use the library thread of std, to compile I have to use the following command:

g++ main.cpp -pthread

And even applies to Ang.

This is the only case I know of the standard library where you have to add some extra option when compiling. Why you have to add the option -pthread? Why can’t it be like the other libraries in std? I’ve looked into it, but I can’t find anything useful.

1 answer

3


Actually, there are other libraries that need this. The main libraries are together in a binary file that is always used when doing the linkediting. Libraries that are not within this binary need to be specified for link individually.

It’s separate because some things aren’t so standard, so someone might want to replace the implementation with another.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.