问题
There is a thread (clang-omp in Xcode under El Capitan) discussing the possibilities of running OpenMP under El Capitan which was Xcode 7 I assume. I am wondering if it is possible to do it Xcode 8.
I have tried both methods mentioned in the thread clang-omp in Xcode under El Capitan, but neither worked for Xcode 8. Considering it was between 2015 - 2016, I assume they work for Xcode 7. Following the setup steps allow me to run OpenMP in command line but not in Xcode 8 (get clang: error: unsupported option '-fopenmp').
回答1:
Based on the methods by eborisch (https://stackoverflow.com/users/846792/eborisch)
[1] sudo port install clang-3.8 ld64 +ld64_xcode
[2] User-defined setting CC /opt/local/bin/clang-mp-3.8
(there is a typo in the original post)
[3] Other C Flags: -fopenmp
[4] Other Linker Flags: -fopenmp
[5] Enable Modules (C and Objective-C): No
[6] Add /opt/local/include/libomp (different from original post) to Header Search Paths under the project's build settings
[7] Add #include <omp.h>
to your script
回答2:
Too much for a comment, but hopefully helpful towards an answer... I have got OpenMP running on macOS at the command line with both the following methods - I presume you could tell Xcode to use either.
Method 1
Install GCC compiler on OSX with homebrew
using:
brew install gcc --without-multilib
Compile using :
gcc-6 -fopenmp OpenMPDemo.c -o OpenMPDemo
Method 2
ALternatively, install llvm compiler with:
brew install llvm
Then compile with:
/usr/local/opt/llvm/bin/clang++ -fopenmp OpenMPDemo.cpp -L/usr/local/opt/llvm/lib -I/usr/local/opt/llvm/include -o demo
来源:https://stackoverflow.com/questions/41979611/is-it-possible-to-run-openmp-in-xcode-8