7

I am using CLion (C++ IDE) for editing a ROS package. I was able to open a package by opening the CMakeLists.txt file. But, I get an error,

"FATAL_ERROR "find_package(catkin) failed. catkin was neither found in the workspace nor in the CMAKE_PREFIX_PATH. One reason may be that no ROS setup.sh was sourced before"

How do I solve this problem? Will I be able to make the project in CLion (If so, how do I) after I make changes to the code or do I have to catkin_make in a separate terminal?

1
  • Every time you open a terminal it automatically (or manually with the source /opt/ros/<distro>/setup.bash command) retrieves catkin environmental variables. For this reason CLion can't find them by itself. Have a look at this workaround: answers.ros.org/question/210534/…
    – alextoind
    Oct 16, 2015 at 14:49

3 Answers 3

12

Try this (for Linux):

  1. Open a command line

  2. Run catkin_make on your package.

  3. source your catkin_workspace/devel/setup.bash file e.g. source ~/my_dev_folder/catkin_ws/devel/setup.bash

  4. Start CLion from [CLion install dir]/bin/clion.sh e.g. cd ~/Downloads/clion-1.2.4/bin && ./clion.sh

CLion should then start with knowledge about the packages in your catkin workspace, through the local environment variables set up by the setup.bash file.

2
  • Adding to the answers by whurobocon&Siong Thye Goh, and Darren H&zx485; CLion docs now do include good advice on ROS integration but you should skim the whole page because there's a lot of points covered. jetbrains.com/help/clion/2018.3/ros-setup-tutorial.html
    – WillC
    Jul 4, 2019 at 1:24
  • It could be worth mentioning that the configuration advice as described on jetbrains help website linked by @willc might not work when using catkin_tools / catkin build instead of catkin_make. I came across this issue myself and posted a corresponding solution here: stackoverflow.com/a/65343315/2422098
    – svenlr
    Dec 17, 2020 at 15:29
4

To add on to what WillC suggested, you can also modify the desktop entry to start the application from bash instead of manually doing so.

To do this, edit the desktop file located at

~/.local/share/applications/jetbrains-clion.desktop

by modifying the line containing Exec= to

Exec=bash -i -c "/INSTALL_LOCATION/clion-2016.3.2/bin/clion.sh" %f
0

To add on to what WillC suggested,CLion reload the last cmake compiling result by default.

However, if you failed to find catkin.cmake during the last attempt even though you source the devel/setup.bash and open CLion, you also cannot find catkin.cmake.

You should click File --> Reload Cmake Project and you should get the right result.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.