3

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').

Cœur
  • 37,241
  • 25
  • 195
  • 267
Mono Wang
  • 83
  • 1
  • 11
  • See:- http://stackoverflow.com/questions/34964055/openmp-support-on-osx-10-11 – saurabheights Feb 01 '17 at 13:40
  • Possible duplicate of [clang-omp in Xcode under El Capitan](http://stackoverflow.com/questions/33668323/clang-omp-in-xcode-under-el-capitan) – Zulan Feb 01 '17 at 14:16
  • @saurabheights I am able to run OpenMP through command line as http://stackoverflow.com/questions/34964055/openmp-support-on-osx-10-11 suggested. But my question is how to do it in Xcode 8. – Mono Wang Feb 01 '17 at 15:21
  • @Zulan II have tried both methods mentioned in the thread http://stackoverflow.com/questions/33668323/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') – Mono Wang Feb 01 '17 at 15:22
  • Ok, given the different xcode version tags, i retract the dupe close vote. – Zulan Feb 01 '17 at 15:40
  • See https://stackoverflow.com/a/55082102/1271826 – Rob Mar 09 '19 at 21:29

2 Answers2

5

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

Community
  • 1
  • 1
Mono Wang
  • 83
  • 1
  • 11
  • I like to conditionally compile in openmp using some `#ifdef _OPENMP ... #endif` statements. Since this involves wrapping the above `#include ` statement, I had to add `_OPENMP` under "Build Settings" -> "Preprocessor Macros" to stop XCode from flagging every openmp method as an error and include the methods in XCodes method suggestions. – Jvinniec Mar 31 '17 at 09:03
1

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
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • I am able to run OpenMP through command line by both clang installed from brew and Macports. But cannot manage do the job through xcode 8. – Mono Wang Feb 01 '17 at 14:25
  • Ok, sorry it didn't help. I won't delete it as it may prove useful for someone else who is happy at the command-line. Good luck. – Mark Setchell Feb 01 '17 at 15:04
  • As far as I know, XCode is an IDE. How to run gcc from the command line seems completely unrelated, then – IceFire Oct 21 '17 at 13:02
  • @IceFire Sometimes it's not possible to do exactly what the OP has requested, sometimes the OP is not aware of alternative ways of achieving something similar - I have often been thanked for providing answers that are *"good enough"* for what folks want to achieve even if the answer doesn't match the tags 100%. Worst case, OP can ignore my answer if it doesn't happen to help. Best case, it helps OP or someone who looks at it later. – Mark Setchell Oct 21 '17 at 13:38
  • @MarkSetchell No, the worst case is that many people have exactly this problem, google for it, find this answer and find out that it is not helpful for solving the issue at all. I am searching for a solution for hours now... anyways, thanks for your answer that might indeed help some folks – IceFire Oct 21 '17 at 13:46