本文介绍了osx和clion,找不到omp.h的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何说服cmake(在CLion中)我有可用的OpenMP标头?我正在尝试编译该项目 SCD ,并且收到以下错误消息

How do I convince cmake (within CLion) I have the OpenMP headers available? I am trying to compile this project SCD and I receive the following error

...
[ 15%] Building CXX object tools/selector/CMakeFiles/selector.dir/source/main.cpp.o
[ 18%] Building CXX object tools/cc/CMakeFiles/cc.dir/source/main.cpp.o
/Users/buddha/github/buddha314/SCD/tools/wcc/source/main.cpp:22:10: fatal error: 'omp.h' file not found
#include <omp.h>
     ^

CMakeLists.txt包含

The CMakeLists.txt includes

SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -pg -fopenmp -DPROFILE ")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -fopenmp -DNDEBUG")

推荐答案

我认为您的问题并非特定于CLion,而是构建过程中使用的工具(即CMake).正如此答案中已经提到的,有一个标准模块可以测试编译器是否支持OpenMP:

I think that your problem is not specific to CLion but the tool that is used for the building process (i.e CMake) . As already mentioned in this answer, there is a standard module for testing if the compiler supports OpenMP:

find_package(OpenMP)
if (OPENMP_FOUND)
    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()

这篇关于osx和clion,找不到omp.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-27 17:22