I'm developing c++ code on Visual Studio 2019 (Version 16.5.4), and for the build i'm targeting Linux Ubuntu 18.04 with gcc 7.5 - both on a remote machine via ssh, and on my local machine via WSL2.
In both cases i have the same problem:when using std::async
, i have to add the compilation flag -lpthread
to gcc's input, in order for the program to compile, otherwise i get
undefined reference to pthread_create
Moreover, the flag has to come after the cpp file name, i.e. g++ -lpthread xxx.cpp
will fail with gcc 7.5, while g++ xxx.cpp -lpthread
works fine.
so far so good, but here's the problem: i can't do a successful build through Visual Studio: when i add the -lpthread flag under Additional Options in the project's C/C++ properties, there doesn't seem to be any effect - the compilation still fails. moreover, since i don't see the flag being added to the full build command line (which is presented read-only), i have no way to see if the flag is actually being sent, and in the right order (namely after the cpp file name). since i don't see any way to manually edit the build command line, I'm out of ideas...anyone?
Thanks.