报错内容:
CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by "common" with any
of the following names:
commonConfig.cmake
common-config.cmake
Add the installation prefix of "common" to CMAKE_PREFIX_PATH or set
"common_DIR" to a directory containing one of the above files. If "common"
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
lidar_location/CMakeLists.txt:37 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/wsk/8359_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/wsk/8359_ws/build/CMakeFiles/CMakeError.log".
Invoking "cmake" failed
报错截图
详情描述:其中common包属于自建包,里面存放共有文件,其他执行文件需要访问该包,并运行包内的头文件。报错内容为找不到这个包,如果读者找不到其他ROS的SDK包,可以直接使用命令下载即可,命令如下,不属于本问题所述情况。
sudo apt-get install ros-melodic-sdk名称
解决方法原理,ros运行各个包是无序的,因此运行其他包的时候,没有先运行common包,故而报这个类型的错误。解决办法,按顺序执行,先运行common包,在运行其他包即可。
方法一:特别笨的
删除其他包,只保留common自建包,运行一次,在把其他包复原。重新catkin_make,解决。
方法二:解决根源
在其他包的package.xml文件里加入一个
<depend>common</depend>
在CMakeLists.txt文件的中加入common
find_package(catkin REQUIRED COMPONENTS
common
)
经过以上就解决了。