Я использую ОС Ma c с CLion IDE, и моя задача - использовать обе параллельные библиотеки (Open MP и MPI).
Проблема в
Undefined symbols for architecture x86_64:
"_MPI_Init", referenced from:
_main in main.c.o
ld: symbol(s) not found for architecture x86_64
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
Я предполагаю , что я не могу понять, как написать для него надлежащие CMakeLists.
Мои CMakeLists выглядят так:
cmake_minimum_required(VERSION 3.15.3)
project(SeqSol C)
set(CMAKE_C_COMPILER "/usr/local/opt/llvm/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/local/opt/llvm/bin/clang++")
set(OPENMP_LIBRARIES "/usr/local/opt/llvm/lib")
set(OPENMP_INCLUDES "/usr/local/opt/llvm/include")
OPTION(USE_OpenMP "Use OpenMP to enable <omp.h>" ON)
OPTION(USE_MPI "Use MPI to enable <mpi.h>" ON)
# Find OpenMP
if (APPLE AND USE_OpenMP)
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
set(OpenMP_C "${CMAKE_C_COMPILER}")
set(OpenMP_C_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
set(OpenMP_C_LIB_NAMES "libomp" "libgomp" "libiomp9")
set(OpenMP_libomp_LIBRARY ${OpenMP_C_LIB_NAMES})
set(OpenMP_libgomp_LIBRARY ${OpenMP_C_LIB_NAMES})
set(OpenMP_libiomp9_LIBRARY ${OpenMP_C_LIB_NAMES})
endif ()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(OpenMP_CXX "${CMAKE_CXX_COMPILER}")
set(OpenMP_CXX_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
set(OpenMP_CXX_LIB_NAMES "libomp" "libgomp" "libiomp9")
set(OpenMP_libomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
set(OpenMP_libgomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
set(OpenMP_libiomp9_LIBRARY ${OpenMP_CXX_LIB_NAMES})
endif ()
endif ()
if (USE_OpenMP)
find_package(OpenMP REQUIRED)
endif (USE_OpenMP)
if (USE_MPI)
find_package(MPI REQUIRED)
endif (USE_MPI)
if (MPI_FOUND)
include_directories(${MPI_INCLUDES_PATH})
link_directories(${MPI_LIBRARIES_PATH})
endif(MPI_FOUND)
if (OPENMP_FOUND)
include_directories("${OPENMP_INCLUDES}")
link_directories("${OPENMP_LIBRARIES}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif (OPENMP_FOUND)
add_executable(SeqSol main.c problem.c fileparse.c)
Как C Компилятор в настройках:
/usr/local/opt/llvm/bin/clang
и я также написал CMake Options:
-DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang
Я могу использовать функции Open MP, но это невозможно для MPI.
Есть предложения?