我一直在尝试使用 clang 构建一个使用 openMP 的库,但出现此错误:
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.
即使我在 /opt/homebrew/Cellar/libomp/11.0.1/include/
中有 omp.h。我已尝试将环境变量 CPLUS_INCLUDE_PATH
设置为指向 /opt/homebrew/Cellar/libomp/11.0.1/include/
,但出现此错误:
ld: library not found for -lomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我使用的命令是:
clang++ -dynamiclib -DNDEBUG -I/opt/homebrew/Cellar/eigen/3.3.9/include/eigen3/ -Xpreprocessor -fopenmp -o libcafx.dylib cafxlibrary.cpp -lomp -std=c++11
我也试过不使用 -lomp
。我还使用自制软件安装了 llvm
和 libomp
,但问题仍然存在。我也试过将 omp.h
直接放在 /opt/homebrew/Cellar/eigen/3.3.9/include/eigen3/Eigen/src/Core
中。任何帮助表示赞赏。