Is it possible to run openmp in Xcode 8?

不打扰是莪最后的温柔 提交于 2020-01-01 06:50:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!