Hi,
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));
t.join();
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:
linux-vdso.so.1 => (0x00007fffa73b5000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0228217000)
libpgatm.so => /opt/pgi/linux86-64/16.10/lib/libpgatm.so (0x00007f0228012000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f0227d03000)
libpgmp.so => /opt/pgi/linux86-64/16.10/lib/libpgmp.so (0x00007f0227a83000)
libnuma.so => /opt/pgi/linux86-64/16.10/lib/libnuma.so (0x00007f0227881000)
libpgc.so => /opt/pgi/linux86-64/16.10/lib/libpgc.so (0x00007f02275f9000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f02272f1000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0226f26000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f0226d10000)
/lib64/ld-linux-x86-64.so.2 (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,
J.D.P