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

6
  • See:- stackoverflow.com/questions/34964055/… Commented Feb 1, 2017 at 13:40
  • Possible duplicate of clang-omp in Xcode under El Capitan Commented Feb 1, 2017 at 14:16
  • @saurabheights I am able to run OpenMP through command line as stackoverflow.com/questions/34964055/… suggested. But my question is how to do it in Xcode 8. Commented Feb 1, 2017 at 15:21
  • @Zulan II have tried both methods mentioned in the thread stackoverflow.com/questions/33668323/…, 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') Commented Feb 1, 2017 at 15:22
  • Ok, given the different xcode version tags, i retract the dupe close vote. Commented Feb 1, 2017 at 15:40

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

I like to conditionally compile in openmp using some #ifdef _OPENMP ... #endif statements. Since this involves wrapping the above #include <omp.h> 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.
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 

5 Comments

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.
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.
As far as I know, XCode is an IDE. How to run gcc from the command line seems completely unrelated, then
@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.
@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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.