我已经使用自制软件安装了 Open-MPI,使用 brew install open-mpi。
如果我mpic++ main.cpp
在命令行中运行,则代码编译正确。然后我可以使用 mpirun a.out
.
现在的问题是,当我在 Clion 中创建 CMakelists.txt 文件时,似乎无法找到 Open-MPI 包:
cmake_minimum_required(VERSION 3.15)
project(project)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_PREFIX_PATH "/usr/local/Cellar/open-mpi/4.0.2/lib")
find_package(OpenMP REQUIRED) #FAILS AT THIS LINE
set(LDFLAGS "-L/usr/local/Cellar/open-mpi/4.0.2/lib")
set(CPPFLAGS "-I/usr/local/Cellar/open-mpi/4.0.2/include")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${LDFLAGS} ${CPPFLAGS} -fopenmp")
add_executable(project main.cpp)
有人可以提供指导吗?我对如何让它工作感到困惑,并且已经尝试了几个小时。我是 Open-MPI 的新手。
当我尝试构建时它产生的错误:
CMake Error at
/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) Call Stack (most recent call first):
/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.15/Modules/FindOpenMP.cmake:477 (find_package_handle_standard_args) CMakeLists.txt:9 (find_package)
谢谢!