Compile programs with OpenMP on macOS and llvm/clang
.
- Download the LLVM-3.8 binaries:
- Download page: http://llvm.org/releases/download.html#3.8.0
- Direct link for MacOS binaries: http://llvm.org/releases/3.8.0/clang+llvm-3.8.0-x86_64-apple-darwin.tar.xz
- Install the binaries:
For example, to install at /opt/llvm38
:
tar xJf clang+llvm-3.8.0-x86_64-apple-darwin.tar.xz
sudo mkdir -p /opt
sudo mv clang+llvm-3.8.0-x86_64-apple-darwin /opt/llvm38
- Configure the environment to use
clang-3.8
:
export CC=/opt/llvm38/bin/clang
export CXX=/opt/llvm38/bin/clang++
export PATH=/opt/llvm38/bin:$PATH
export C_INCLUDE_PATH=/opt/llvm38/include:/usr/local/include:/usr/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/opt/llvm38/include:/usr/local/include:/usr/include:$CPLUS_INCLUDE_PATH
export LIBRARY_PATH=/opt/llvm38/lib:/usr/local/lib:/usr/lib:$LIBRARY_PATH
export DYLD_LIBRARY_PATH=/opt/llvm38/lib:$DYLD_LIBRARY_PATH
For most programs, setting the environmental settings should be enough.