4

I've been trying to build a library that uses openMP using clang but I get this error:

In file included from cafxlibrary.cpp:2:
In file included from /opt/homebrew/Cellar/eigen/3.3.9/include/eigen3/Eigen/Dense:1:
/opt/homebrew/Cellar/eigen/3.3.9/include/eigen3/Eigen/Core:266:10: fatal error: 'omp.h' file not found
#include <omp.h>
         ^~~~~~~
1 error generated.

Even though I have omp.h in /opt/homebrew/Cellar/libomp/11.0.1/include/. I've tried setting up the environment variable CPLUS_INCLUDE_PATH to point to /opt/homebrew/Cellar/libomp/11.0.1/include/ but I get this error instead:

ld: library not found for -lomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The command I'm using is:

clang++ -dynamiclib -DNDEBUG -I/opt/homebrew/Cellar/eigen/3.3.9/include/eigen3/ -Xpreprocessor -fopenmp -o libcafx.dylib cafxlibrary.cpp -lomp -std=c++11

I've also tried without -lomp. I also have installed llvm and libomp using homebrew but the problem persists. I've also tried placing omp.h directly in /opt/homebrew/Cellar/eigen/3.3.9/include/eigen3/Eigen/src/Core. Any help is appreciated.

  • It is looking for `libomp.dylib` ... instead of passing `-lomp` to the linker, try `-L/opt/homebrew/lib/libomp.dylib` or wherever the path to libomp is – Richard Barber Mar 18 '21 at 07:27
  • Can you maybe add the output of `clang -v ...` to the post, so that we can see more of the compiler invocation that happens in the background? – Michael Klemm Mar 18 '21 at 08:13
  • 2
    This seems very close to being a duplicateof your other question https://stackoverflow.com/questions/66663120/fatal-error-omp-h-file-not-found-using-clang-on-apple-m1 which I have answered. – Jim Cownie Mar 19 '21 at 08:43

0 Answers0