catkin_make时报错找不到custom include custom.h

Posted hiram-zhang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了catkin_make时报错找不到custom include custom.h相关的知识,希望对你有一定的参考价值。

参考:
https://answers.ros.org/question/195467/catkin-unable-to-include-custom-libraries/

报错内容:
/home/zhanghu/catkin_ws/src/map_img_proccess/src/map_img_load.cpp:1:26: fatal error: map_img_load.h: 没有那个文件或目录
 #include "map_img_load.h"

解决办法:

You should create a folder named include/ < name of package > / (include/proj_utils in your case) where you put all the header files (*.hpp) of the package.

Then the package that exports the library should have the following in the CMakeLists to be able to export the header files:

catkin_package(
INCLUDE_DIRS include
 LIBRARIES map_img_load
)
include_directories( include ${catkin_INCLUDE_DIRS})

Then the other package should be able to see the header files as (you might have to run catkin_make or cmake first):

 #include <name_of_package/header_file.h>



完整的CMakeLists.txt:
--------------------------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8.3)
project(map_img_proccess)

find_package(catkin REQUIRED COMPONENTS
  roscpp
)

find_package(OpenCV REQUIRED)

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES map_img_load
#  CATKIN_DEPENDS roscpp
#  DEPENDS system_lib
)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
)



add_library(map_img_load src/map_img_load.cpp)
target_link_libraries(map_img_load ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})

add_executable(main src/main.cpp)
target_link_libraries(main map_img_load ${catkin_LIBRARIES} )

--------------------------------------------------------------------------------------------

同时:头文件中有条件编译的千万别忘记最后的#endif
#ifndef ...
#define ...
...
...
#endif

以上是关于catkin_make时报错找不到custom include custom.h的主要内容,如果未能解决你的问题,请参考以下文章

关于安装mySQL时报错找不到vcruntime140_1.dll的解决方案

关于安装mySQL时报错找不到vcruntime140_1.dll的解决方案

IntelliJ IDEA无法读取src下的配置文件 报错找不到 解决方案

二进制安装mysql5.6.39报错找不到libnuma.so.1库文件

maven报错找不到依赖

报错ES报错找不到Gson类