catkin_make编译时,往往需要自动链接同一个工作空间的其他包的头文件。否则会出现类似如下的错误:
/home/xx/xx_ws/srcA_package/src/db.hpp:13:26: fatal error: B_package/alax.h: No such file or directory
#include <B_package/alax.h>
^
这需要对包进行配置,假设包A_package需要引用B_package的头文件(例如由message,srv,action自动生成的头文件)。步骤如下:
1.在A_package包的package.xml中添加编译和运行的依赖库,如下:
<build_depend>B_package</build_depend>
<run_depend>B_package</run_depend>
2.在A_package包的CMakeList.txt中的find_package添加B_package如下:
find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs B_package )
3.在A_package包的CMakeList.txt中的include_directories添加${catkin_INCLUDE_DIRS}如下:
include_directories(include ${catkin_INCLUDE_DIRS})