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):
- Install clang-omp using homebrew:
brew install clang-omp
- Create a new Xcode project
- Add a new user-defined setting CC with the value
/usr/local/bin/clang-omp
under the project's build settings - Add
-fopenmp
to Other C Flags under the project's build settings - Add
/usr/local/include
to Header Search Paths under the project's build settings - Add
/usr/local/lib
to Library Search Paths under the project's build settings - Set Enable Modules (C and Objective-C) to
No
under the project's build settings - Add
/usr/local/lib/libiomp5.dylib
to Link Binary With Libraries under the project's build phases - Make a symbolic link via
sudo ln -s /usr/local/bin/clang-omp++ /usr/local/bin/clang++-omp
using the terminal - 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
Calling Erase with Iterator VS Const_Iterator
How to Decide If a Template Specialization Exist
Is There a Gcc Preprocessor Directive to Check If the Code Is Being Compiled on a 64 Bit MAChine
C++11 'Native_Handle' Is Not a Member of 'Std::This_Thread'
Why Does C++11 Not Support Anonymous Structs, While C11 Does
String Comparison with the Most Similar String
Calling Constructor with Braces
Why Can't a Function Go After Main
C++ Sqrt Function Precision for Full Squares
What Is the Purpose of Max_Digits10 and How Is It Different from Digits10
Mapping Elements in 2D Upper Triangle and Lower Triangle to Linear Structure
How to Apply Content Not Explicitly Cited from the Normative References to the C++ Standard