Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the new C++ threading support on Mac OS X with clang?

I just want to compile the following program on Mac OSX 10.8 using Apple clang version 4.1 (tags/Apple/clang-421.11.66):

#include <thread>

using namespace std;

int main() {

    cout << "Hello world";

}

But I get:

../src/FirstCAgain.cpp:13:10: fatal error: 'thread' file not found
#include <thread>

I enabled c++11 support and I'm using the Eclipse C/C++ Development Tooling.

The question is: How do I get the new C++ threading support on Mac OS X ?

like image 274
rogergl Avatar asked Jan 05 '13 22:01

rogergl


1 Answers

You need to use the new libc++, which isn't the default:

clang++ -stdlib=libc++ threadtest.cpp 

(Of course you also need to include iostream, but I assume that wasn't you confusion.)

like image 180
Rob Napier Avatar answered Nov 12 '22 22:11

Rob Napier