9

I like to use openmp in a c++ project using Xcode as IDE. Unfortunately, Apple's Clang compiler does not support openmp (see here), so I installed clang-omp. I exactly followed the instructions given on that website to use it within Xcode, but I get the error message can't exec '/usr/local/bin/clang++-omp' (No such file or directory). I tried to compile the simple example given on their website via terminal and I got it to work when I compile it via clang-omp++ -fopenmp file.cpp. For me it looks like Xcode should search for /usr/local/bin/clang-omp++ (which exists in contrast to /usr/local/bin/clang++-omp). After making a symlink as suggested in the comments I get another error message: library not found for -liomp5. How can I fix this?

Community
  • 1
  • 1
DaPhil
  • 1,509
  • 4
  • 25
  • 47
  • what about making a symbolic link? `sudo ln -s /usr/local/bin/clang-omp++ /usr/local/bin/clang++-omp` – Gilles Nov 12 '15 at 09:42
  • @Gilles Nice idea, but I still get the error message although the file now exists... – DaPhil Nov 12 '15 at 09:46
  • I just noticed that there seems to be another error: library not found for -liomp5. I will add that to the question. – DaPhil Nov 12 '15 at 09:50

2 Answers2

8

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
DaPhil
  • 1,509
  • 4
  • 25
  • 47
  • 1
    @JosephK I know it's a little late, but try running `brew update` before `brew install`. – David Ganster Mar 26 '16 at 20:01
  • 9
    **Note (July 2016)**: `clang-omp` has been "[removed](https://github.com/Homebrew/homebrew-core/commit/c57e307)" from brew, OpenMP now being directly supported by upstream LLVM (available on brew as well). Regarding Xcode integration now, though, I'm not sure. – Adriweb Jul 17 '16 at 09:35
  • 1
    I've installed llvm38 from homebrew and while `-fopenmp` flag now correctly gets recognizer, I get a compile error stating that `omp.h` does not exists. I searched for the file and it really does not exist. What to do now? – DoDo Jul 26 '16 at 18:21
  • If you install clang-3.8 and above from MacPorts, -fopenmp "just works." – eborisch Dec 22 '16 at 14:05
  • To use in Xcode from MacPorts and then, similar to above: [1] `sudo port install clang-3.8 ld64 +ld64_xcode` [2] User-defined setting CC `/opt/local/bin/clang-mp/3.8` [3] Other C Flags: `-fopenmp` [4] Other Linker Flags: `-fopenmp` [5] Enable Modules (C and Objective-C): `No` [6] And done. The include and library search paths and linking requirements are baked into clang-mp-3.8. You will need `#include ` as always. (Inspired by Jan-Michael Tressler's openmp-dev post.) – eborisch Dec 22 '16 at 15:00
  • What about newer `XCode`? Is there a simple way? – Royi Sep 02 '18 at 22:09
1

OpemMP runtimes are usually not delivered with clang, you can download and install from: https://www.openmprtl.org

Undo
  • 25,519
  • 37
  • 106
  • 129
Abnaxus
  • 11
  • 2
  • 2
    Whilst this may theoretically answer the question, [it would be preferable](//meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Bhargav Rao Sep 21 '16 at 14:46