Clang-Omp in Xcode Under El Capitan

clang-omp in Xcode under El Capitan

In case anyone else is trying to get clang-omp under Xcode to work, the correct way is (following the official instructions):

  1. Install clang-omp using homebrew: brew install clang-omp
  2. Create a new Xcode project
  3. Add a new user-defined setting CC with the value /usr/local/bin/clang-omp under the project's build settings
  4. Add -fopenmp to Other C Flags under the project's build settings
  5. Add /usr/local/include to Header Search Paths under the project's build settings
  6. Add /usr/local/lib to Library Search Paths under the project's build settings
  7. Set Enable Modules (C and Objective-C) to No under the project's build settings
  8. Add /usr/local/lib/libiomp5.dylib to Link Binary With Libraries under the project's build phases
  9. Make a symbolic link via sudo ln -s /usr/local/bin/clang-omp++ /usr/local/bin/clang++-omp using the terminal
  10. Use #include <libiomp/omp.h> to be able to use openmp in your project

Is it possible to run openmp in Xcode 8?

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

clang: error: : errorunsupported option '-fopenmp' on Mac OSX El Capitan building XGBoost

You installed gcc with Homebrew, yet the error is from clang. That should simply mean that your default compiler still points to clang instead of the newly installed gcc. If you read the comments in the Makefile, you'll see the following lines:

# choice of compiler, by default use system preference.
# export CC = gcc
# export CXX = g++
# export MPICXX = mpicxx

and in your case, you don't want the system one.

Note: gcc for the system points to clang:

$ which gcc
/usr/bin/gcc
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin15.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Instead, point those variables to something in /usr/local/bin, e.g.:

$ export CC=/usr/local/bin/gcc

and similar for the other two variables, CXX and MPICXX, e.g.:

$ export CC=/usr/local/bin/gcc;CXX=/usr/local/bin/g++;MPICXX=/usr/local/bin/mpicxx

How to deal with clang: error: unsupported option '-fopenmp' on travis?

On apple's llvm, -fopenmp is not supported. One should use brew's llvm.

The following ables to link openmp:

 - brew install llvm libomp
- export CPP=/usr/local/opt/llvm/bin/clang;

For reference, the issue where there are all the commands: https://github.com/bluesheeptoken/CPT/issues/68#issuecomment-563342866

increasing number of threads in openmp in xcode

I am sure this answer is coming way too late. But hopefully might help someone else. I was struggling with the same issue and solved it by :
Adding -fopenmp to Other C++ flags as well as C flags.

Hope this helps someone.



Related Topics



Leave a reply



Submit