Enable OpenMP support in clang in Mac OS X (sierra & Mojave)

后端 未结 4 1327
长情又很酷
长情又很酷 2020-11-28 09:37

I am using Mac OS X Sierra, and I found that clang (LLVM version 8.1.0 (clang-802.0.38)) does not support OpenMP: when I run clang -fopenmp program_name.c, I go

4条回答
  •  情深已故
    2020-11-28 10:21

    MacOS Mojave with CMake

    1. Install LLVM with openmp and libomp with brew

       brew update
       brew install llvm libomp
      
    2. add include directories and link directories in CMakeList.txt

       include_directories("/usr/local/include" "/usr/local/opt/llvm/include")
       link_directories("/usr/local/lib" "/usr/local/opt/llvm/lib")
      
    3. run CMake with the new compilers

       cmake -DCMAKE_C_COMPILER="/usr/local/opt/llvm/bin/clang" -DCMAKE_CXX_COMPILER="/usr/local/opt/llvm/bin/clang++" ..
      

    The clang version is 7.0.1 at time of writing

提交回复
热议问题