码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-03-03 00:37:14      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:千万   pretty   following   required   tab   ros   folder   ade   参考   

参考:
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

标签:千万   pretty   following   required   tab   ros   folder   ade   参考   

原文地址:https://www.cnblogs.com/hiram-zhang/p/8495511.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!