C++ 11 Threads, Error Pure virtual function called

beagleboneblack, c++, c++11, multithreading, pthreads

Solution

This is a bug in either libstdc++ or Clang, depending on who you ask. It should work if you are using a version of Clang released after October 2013. What do you see when you run `g++ --version`?

As a workaround, you could try using this command line instead. I don't guarantee that it would work; please post a comment with your results.

g++ -pthread -std=c++11 -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_{1,2,4} thread1.cpp

Here's the bug report:

http://llvm.org/bugs/show_bug.cgi?id=12730

And here's the official fix to the Clang driver:

https://llvm.org/viewvc/llvm-project?view=revision&revision=191707

I don't know if this was also previously a bug in the GCC driver, and/or whether it's been fixed.

Problem

here is a very minimal C++11 Thread API code that I am trying to compile ``` #include<iostream> #include<thread> using namespace std; void threadFunction(void) { cout<<"hello from thread:";//<<this_thread::get_id()<<endl; } int main() { std::thread t(threadFunction); t.join(); return 0; } ``` On Compiling this as g++ thread1.cpp -pthread -std=c++11 I get the following error pure virtual method called terminate called without an active exception Aborted What wrong, can someone please help Note that I am compiling this on Beaglebone Black with ARM A8 processor

Original source

Related problems