catkin_make编译问题--Project 'B' tried to find library 'A'. The library is neither a target nor built/installed properly.

CMake Error at /home/sany/WorkSpace/test_ws/devel/share/A/cmake/AConfig.cmake:173 (message):
  Project 'B' tried to find library 'A'.  The library is neither a target nor
  built/installed properly.  Did you compile project 'A'? Did you
  find_package() it before the subdirectory containing its code is included?
Call Stack (most recent call first):
  /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package)
  B/CMakeLists.txt:10 (find_package)  

在编译的时候遇到上述错误,复现方法如下:

1.  创建ros的A包:

catkin_create_pkg A rospy roscpp

修改 A包的CMakeLists.txt,表示A包提供头文件INCLUDE_DIRS和LIBRARIES A给其他包依赖。

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES A
#  CATKIN_DEPENDS geometry_msgs nav_msgs roscpp rospy std_msgs task_manager tf2
#  DEPENDS system_lib
)

2. 创建ros的B包:

catkin_create_pkg B rospy roscpp A

3. catkin_make,即得到上述错误。

原因分析:

A包输出了并不存在的库(LIBRARIES A),导致B包find_package()在寻找A库的时候无法找到。

当去掉LIBRARIES A的时候,find_package()将不会寻找LIBRARIES A,因此CMAKE配置通过。 

posted @ 2020-08-27 11:33  TiderFang  阅读(1804)  评论(0编辑  收藏  举报