3

I followed the excellent walkthrough on how to compile clang(++) with OpenMP support for Mac OS X found here. However, while compiling a simple test program:

#include <iostream>

int main(int argc, char** argv)
{
    std::cout << "Hello world!" << std::endl;
    return 0;
}

...I simply get:

$> clang2++ -Wall -std=c++11 -stdlib=libc++ -fopenmp -o openmp openmp.cpp 
openmp.cpp:2:10: fatal error: 'iostream' file not found
#include <iostream>

My newly compiled clang project doesn't seem to include libc++ and even if the standard directories are included ("standard" afaik), i.e:

/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)

...it still doesn't work. Has anyone else encountered this and found a solution? Thanks.

Community
  • 1
  • 1
gustafbstrom
  • 1,622
  • 4
  • 25
  • 44

2 Answers2

1

I have successfully compiled clib++ by adding a missing step in the Clang / OpenMP build procedure.

On the Clang / OpenMP page (http://clang-omp.github.io/) it asks you to download the following:-

$ git clone https://github.com/clang-omp/llvm
$ git clone https://github.com/clang-omp/compiler-rt llvm/projects/compiler-rt
$ git clone -b clang-omp https://github.com/clang-omp/clang llvm/tools/clang

If you want to include c++11 support you should also download:- $git clone https://github.com/llvm-mirror/libcxx llvm/projects/libcxx

One of the build parameters is LLVM_EXTERNAL_LIBCXX_SOURCE_DIR (defined in CMakeCache.txt) which expects libcxx in this location.

*Note. I had to make a slight modification to the build instructions referred to in Kyle Halladays OSX Mavericks instructions, replacing: ../configure --enable-optimized with ../configure --enable-optimized CC=/usr/bin/clang CXX=/usr/bin/clang++

0

ok you can include the directory that contain iostream clang2++ -std=c++11 -stdlib=libc++ -fopenmp -o openmp openmp.cpp -I /usr/include

if /usr/include contain iostream file