I am working with a catkin workspace in C++ and when I open it in an IDE, the cmake command gives the following error:

CMake Error at CMakeLists.txt:65 (message): 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.

However, catkin is installed on my machine as "rospack find catkin" gives the path where catkin is saved which is /opt/ros/noetic/share/catkin.

Moreover, the workspace is sourced with the command "source /opt/ros/noetic/setup.bash"

Appreciate any help!

  • $\begingroup$ Are you using catkin build or catkin_make? What happens if you cd to catkin_ws directory and run that command in the terminal? $\endgroup$
    – Mike973
    Commented Nov 7, 2023 at 21:42
  • $\begingroup$ Hi! I am using catkin_make. Running catkin_make in my workspace root works fine. $\endgroup$
    – Emco
    Commented Nov 8, 2023 at 11:03

1 Answer 1


Since catkin_make works fine in the terminal, it means your problem is with how you have configured the IDE. A ros package is not a simple cmake project, and you can not directly invoke the cmake application.

You don't tell us which IDE you are using. If it happens to be Visual Studio, there are already a large number of existing answers on this site, and you should search for one of them.

  • $\begingroup$ You can just invoke cmake on any individual package assuming that you have invoked cmake make and make install on all the dependencies beforehand and sourced the install setup files. Which is likely what is missing in the ide configuration. $\endgroup$
    – Tully
    Commented Apr 6 at 21:32

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.