1

I'm trying to build a program using OpenMP, but I'm not able to get clang to recognize the library. I'm using a newer version of clang:

λ clang++ --version
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

And I'm on OS X 10.10.5. When I try compiling, this is the error message that I get:

λ clang++ -fopenmp src/maranj_NumberCheck.cpp
ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I thought that OpenMP was included in Clang after 3.7, but I'm on 7.0.2, so I don't understand why I'm having this problem. I have seen this question, but that is over 3 years old, and I think that OpenMP wasn't a part of Clang yet.

What should I be doing differently?

Lily Mara
  • 3,859
  • 4
  • 29
  • 48

1 Answers1

0

clang tries to link -fopenmp with libgomp by default, which probably is not available in your system. Try to link to libomp or libiomp5

-fopenmp=libomp

or

-fopenmp=libiomp5
Kochoba
  • 391
  • 3
  • 7
  • 1
    Those give me `clang: error: unsupported argument 'libop' to option 'fopenmp='` and `ld: library not found for -liomp5` – Lily Mara Mar 16 '17 at 03:34
  • @NateMara It should be libomp. Try a `sudo find / -name "libomp*"` or `sudo find / -name "libiomp*"` to see if the libraries exist in your system. If they don't you need to download and compile the library from [here](http://openmp.llvm.org/) – Kochoba Mar 16 '17 at 04:03