Using std::thread ends up with "pure virtual method cal


I am trying to use the C++11 feature std::thread on my Ubuntu 17.04 box.
Here is my simple helloworld program:

#include <thread>
#include <iostream>
#include <cstdlib>

void mythread(void* d)
  std::cout << "Hello from thread!" << std::endl;
int main()
  std::thread t(std::thread(mythread, nullptr));
  return EXIT_SUCCESS;

I compile this simple test with PGI pgc++ 16.10-0 64-bit target on x86-64 Linux -tp haswell using the following command:

  $ pgc++ test.cpp -o test -std=c++11 -lpthread

No error is printed but when I run the code, here is what I get:

  pure virtual method called
  terminate called without an active exception
  Abandon (core dumped)

What am I missing? Is there a library I should link my binary with?

For information, my box has gcc 4.9.2 and this is what ldd test prints: =>  (0x00007fffa73b5000) => /lib/x86_64-linux-gnu/ (0x00007f0228217000) => /opt/pgi/linux86-64/16.10/lib/ (0x00007f0228012000) => /usr/lib/x86_64-linux-gnu/ (0x00007f0227d03000) => /opt/pgi/linux86-64/16.10/lib/ (0x00007f0227a83000) => /opt/pgi/linux86-64/16.10/lib/ (0x00007f0227881000) => /opt/pgi/linux86-64/16.10/lib/ (0x00007f02275f9000) => /lib/x86_64-linux-gnu/ (0x00007f02272f1000) => /lib/x86_64-linux-gnu/ (0x00007f0226f26000) => /lib/x86_64-linux-gnu/ (0x00007f0226d10000)
        /lib64/ (0x000055e3522fe000

Not sure the PGI libstdc++ is used here.
/opt/pgi/linux86-64/16.10/lib is the first entry in my LD_LIBRARY_PATH.

Thanks very much,


Hello. First of all, you need to make sure the gcc version is 5.2 or better.
gcc 4.4.7 will fail because it lacks the lib support pgc++ needs.

% g++ -o test_g++ test.cpp -std=c++0x -lpthread
% icc -o test_intel test.cpp -std=c++0x -lpthread
% pgc++ -std=c++0x -o test_pgi test.cpp -lpthread

all create executables.

test_g++ | test_intel | test_pgi
all result in

Hello from thread!



Thanks for this information. I didn’t know gcc 5.2 was needed.
Do you know if this is documented somewhere?


We need a g++ that supports C++11 and C++14 features in order
for pgc++ to also support them - gcc headers and libs need to be right.

Release Notes

PGI Câ� +â� + Compiler â—¦ Integrated EDG release 4.13 and enabled interoperability with GCC 5.2, 5.3, 5.4, 6.0, 6.1, 6.2, and 6.3. To take full advantage of the new Câ� +â� +â� 11 features supported by GCC 5.1 and later, use the PGCâ� +â� + compiler option --câ� +â� +â� 11.
â—¦ Comprehensive support for Câ� +â� +â� 14; co-installation with GCC version 5.0 or greater is required. Enable Câ� +â� +â� 14 features with the PGCâ� +â� + compiler option --câ� +â� +â� 14.
â—¦ Added Câ� +â� +â� 11 support to PGCâ� +â� +â� when PGCâ� +â� + is used as the nvcc host compiler; this support requires a patched post-CUDA-8.0-production version of nvcc. Contact for more information.