【发布时间】:2016-02-22 12:55:49
【问题描述】:
我有三个程序以串行代码计算数量 S,并使用 MPI 和 OpenMP 并行计算。所有程序都需要相同的头文件 utils.h。不知何故,在运行 cmake .. 之后,我需要运行两次 make 才能正确编译程序,因为第一次运行会导致链接错误(标准库似乎没有链接)。任何想法为什么会这样?
cmake_minimum_required(VERSION 2.6)
project(compute_S)
find_package(MPI)
enable_language(C)
include_directories(${MPI_INCLUDE_PATH})
set(CMAKE_C_FLAGS "-std=c99")
add_executable(compute_S compute_S.c utils.h)
set(CMAKE_C_FLAGS "-std=c99")
add_executable(compute_S_MPI compute_S_MPI.c utils.h)
set(CMAKE_C_FLAGS "-std=c99 -fopenmp")
add_executable(compute_S_OpenMP compute_S_OpenMP.c utils.h)
target_link_libraries(compute_S ${catkin_LIBRARIES})
target_link_libraries(compute_S_MPI ${MPI_C_LIBRARIES})
target_link_libraries(compute_S_OpenMP ${catkin_LIBRARIES})
您可以通过运行以下命令重现错误
mkdir test
cd test
git clone https://github.com/Zetison/exerciseSet4
cd exerciseSet4
cmake .
make
【问题讨论】:
-
什么是
catkin_LIBRARIES? -
这里解释:wiki.ros.org/catkin/CMakeLists.txt(搜索Catkin_LIBRARIES)