我的项目结构如下:
utils
include
utils
image_utils.h
CMakelists.txt
package.xml
graph
src
graph.cpp
CMakelists.txt
package.xml
我正在尝试在graph.cpp
中使用image_utils.h
。
utils内部的CMakelists
如下所示:
cmake_minimum_required(VERSION 3.0.2)
project(utils)
find_package(catkin REQUIRED COMPONENTS roscpp)
catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS roscpp
)
include_directories(
include
${catkin_INCLUDE_DIRS}
)
add_library(${PROJECT_NAME} INTERFACE)
target_link_libraries(${PROJECT_NAME} INTERFACE ${catkin_LIBRARIES} )
install(
DIRECTORY include/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
)
在CMakelists
内部图中,我调用find_package(catkin REQUIRED COMPONENTS roscpp)
,如下所示:
cmake_minimum_required(VERSION 3.0.2)
project(pose_graph)
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS "-std=c++11")
find_package(catkin REQUIRED COMPONENTS roscpp std_msgs cv_bridge utils)
find_package(OpenCV 3.4 REQUIRED)
include_directories(${catkin_INCLUDE_DIRS} )
catkin_package(CATKIN_DEPENDS utils)
add_executable(graph src/graph.cpp)
target_link_libraries(graph ${catkin_LIBRARIES} ${OpenCV_LIBS} utils)
图形的package.xml
具有以下相关标记:
<depend>utils</depend>
我的错误消息是:
graph.cpp:12:10: fatal error: utils/image_utils.h: No such file or directory
#include "utils/image_utils.h"
^~~~~~~~~~~~~~~~~~~~~
你知道我做错了什么吗?
2条答案
按热度按时间ccgok5k51#
您需要将文件夹结构重新排列为
utils/include/utils/image_utils.h
,然后在CMakeLists.txt
文件中添加一个add_library(...)
调用。watbbzwu2#
终于找到了。下面是我的
CMakelists
文件:效用:
图表: