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配置通過。 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM