缺少:OpenMP_C_标志OpenMP_C_LIB_NAMES
我很难在MacOSX上使用OpenMP编译一个项目。 错误为:
CMake Error at /usr/local/Cellar/cmake/3.10.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
Call stack most recent call first)
/usr/local/Cellar/cmake/3.10.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/usr/local/Cellar/cmake/3.10.2/share/cmake/Modules/FindOpenMP.cmake:447 (find_package_handle_standard_args)
libRORPO/CMakeLists.txt:7 (find_package)
在工程中搜索OpenMP关联的CMakeList文件如下:
# RORPO Lib
project(libRORPO)
cmake_minimum_required(VERSION 2.8)
# FIND OPENMP
find_package( OpenMP REQUIRED)
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}
${OpenMP_EXE_LINKER_FLAGS}")
endif()
# ADD FILES
file(GLOB_RECURSE RORPO_HEADERS *.hpp *.h)
file(GLOB_RECURSE RORPO_SOURCES *.c)
add_library(RORPO ${LIB_TYPE} ${RORPO_SOURCES} ${RORPO_HEADERS})
install( FILES ${RORPO_HEADERS} DESTINATION include/libRORPO)
install( TARGETS RORPO DESTINATION lib)
我使用GCC-7和clang-omp验证了OpenMP安装是否运行良好。我也搜索过类似的虫子。回复指出,cmake中最近有一个包允许查找OpenMp。我重新安装了CMAKE以获得最新版本,但它仍然不能工作。 我不是cmake配置方面的专家,如果您能指导我,我将不胜感激。
解决方案
我在中找到了一个解决方案:http://stechschulte.net/2016/03/20/openmp-osx-cmake.html
诀窍是cmake必须与指向clang-omp:
的CC和CXX环境变量一起运行CC=clang-omp CXX=clang-omp++ cmake
请注意,clang-omp和clang-omp++必须在通过以下方式安装llvm后定义:
brew install llvm
并创建两个符号链接:
ln -s /usr/local/opt/llvm/bin/clang /usr/local/bin/clang-omp
ln -s /usr/local/opt/llvm/bin/clang++ /usr/local/bin/clang-omp++
相关文章