Tag Archives: Cmake Complie openmp Error

[Solved] Mac Cmake Complie openmp Error: fatal error: ‘omp.h‘ file not found

Mac OS 11.5.2, cmake default compiler appleclang 12.0.5

Make keeps reporting errors after compiling

fatal error: 'omp.h' file not found
#include<omp.h>

The reason is that a.cpp file introduces OpenMP, OMP.H

It can be compiled successfully through G + +, but the make default clang compilation in MAcc is not successful. In other words, it cannot be compiled through cmake on Mac

Try to resolve:

Adding before the project line of cmake has no effect

SET(CMAKE_C_COMPILER "/usr/bin/gcc")
SET(CMAKE_CXX_COMPILER "/usr/bin/g++")

On the command line, the export cxx = “usr/bin/G + +” variable also has no effect

Solution

Brew install libomp

brew install libomp

Change the path corresponding to OMP. H where. CPP introduces OMP. H

#include</usr/local/opt/libomp/include/omp.h>