What are the correct link options to use std::thread in GCC under linux?
I think on Linux pthread is used to implement std::thread
so you need to specify the -pthread
compiler option.
As this is a linking option, this compiler option need to be AFTER the source files:
$ g++ -std=c++0x test.cpp -pthread
In addition to using -std=c++0x
and -pthread
you must not use -static
.
-std=c++11 -static -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive
works together with -static
!!!
See here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52590#c4