在使用Clion进行ROS开发时编译CMakeLists.txt出现以下报错
CMake Error at CMakeLists.txt:65 (message):
find_package(catkin) failed. catkin was neither found in the workspace norin the CMAKE_PREFIX_PATH.One reason may be that no ROS setup.sh was sourced before.
原因:Clion软件在以快捷方式打开后并没有加载catkin的一些环境。因此Clion是找不到上面报错的代码中包含的运行包的。
解决方法:
查找clion所在的安装位置
locate clion.sh
若出现报错:Command 'locate' not found, but can be installed with:
则输入
sudo apt install mlocate
再次输入
locate clion.sh
可以得到clion的路径
我的路径如下
进入该路径
cd /snap/clion/184/bin
之后再运行Clion即可
./clion.sh