ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

CMake error while integrating catkin workspace with qtCreator

asked 2015-08-13 19:16:09 -0500

Naman gravatar image

updated 2022-01-22 16:16:31 -0500

Evgeny gravatar image

Hi all,

I am trying to open a ros package in Qt Creator following . In Qtcreator, I opened the CmakeLists.txt file from ~/catkin_ws/src and changed the build directory properly to ~/catkin_ws/build and then ran cmake. I am following this answer.

Also, I set the cmake arguments for devel and install directories properly which are inside catkin_ws using this line


But when I run cmake in qtCreator, I get the following error:

CMake Error at /opt/ros/indigo/share/catkin/cmake/safe_execute_process.cmake:11 (message):
returned error code 1
Call Stack (most recent call first):
/opt/ros/indigo/share/catkin/cmake/all.cmake:186 (safe_execute_process)
/opt/ros/indigo/share/catkin/cmake/catkinConfig.cmake:20 (include)
CMakeLists.txt:52 (find_package)
File "/home/sharath/catkin_ws/build/catkin_generated/", line 20, in <module>
from catkin.environment_cache import generate_environment_script
ImportError: No module named catkin.environment_cache
Traceback (most recent call last):
-- Using CATKIN_DEVEL_PREFIX: /home/sharath/catkin_ws/devel
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/sharath/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.6.14
-- Configuring incomplete, errors occurred!
See also "/home/sharath/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/sharath/catkin_ws/build/CMakeFiles/CMakeError.log".

Here are the problems I am facing,

1) First of all , the above error appears . I tried updating the python modules by sudo pip install -U catkin_pkg but that does not help.

2) Also interestingly after running the cmake in qtcreator , my catkin_make doesn't run in the ~/catkin_ws

Now I cannot use ros aliases like roscore and stuff even though I have already sourced catkin_ws/devel/setup.bash and also /opt/ros/indigo/setup.bash in my bashrc. Restarted the terminal , but still catkin_make and aliases dont run. However this gets solved the moment I source again inside terminal for /opt/ros/indigo/setup.bash. This solves and now all ros commands work normally without sourcing only until I run Cmake from qtcreator and then ros commands dont work and need to be sourced again from terminal. Is the setup.bash in catkin_ws/devel getting modified or something ?

3) However my main problem is how to solve the qt creator error above.?

I tried setting up the workspace again but these problems recur in the same manner. There's something I am missing.

Thanks @Simon for the answer! I tried the "old_way" mentioned in the answer and replaced the CMakeLists.txt in the ~/catkin_ws/src/ with the file it links to. Then, I opened that CMakefile in qtcreator and specified build directory as ~/catkin_ws/build/ and then ran cmake and then, I get the same error as mentioned above. Now, when I run catkin_make ...

edit retag flag offensive close merge delete


how do you open qtcreator?

Simon Schmeisser gravatar image Simon Schmeisser  ( 2015-08-17 02:31:46 -0500 )edit

I seem to have the same problem on a Mac. My guess is that qtCreator (which I start from the terminal by calling "/path/to/Qt\ Creator) is not starting cmake in the same environment with the same environment variables, as the one from which qtcreator itself was started

igor gravatar image igor  ( 2015-10-22 12:52:48 -0500 )edit

Hi Naman, I've got exactly the same issue. Did you finally manage to fix this? I'm quite a beginner with Cmake and ROS. I tried many things but nothing successful.. thanks

Clément Z gravatar image Clément Z  ( 2016-02-14 05:53:04 -0500 )edit

I'm not sure what exactly you mean by "same", but try the following:

  1. in a terminal make sure cmake works and all path are set
  2. start qtcreator from this terminal
  3. see if it works
Simon Schmeisser gravatar image Simon Schmeisser  ( 2016-02-16 04:33:50 -0500 )edit

hello, I also encounter this problem, have you solved the problem?

yin gravatar image yin  ( 2016-11-27 20:02:15 -0500 )edit

5 Answers

Sort by » oldest newest most voted

answered 2016-05-01 08:44:35 -0500

JackChen gravatar image

Just run you qtcreator in the terminal by "qtcreator" instead of clicking the icon, so it will know $PATH

edit flag offensive delete link more



It fucking works dude!

Farid gravatar image Farid  ( 2016-08-26 07:08:47 -0500 )edit

answered 2017-06-20 17:02:33 -0500

amcelroy gravatar image


I had the same problem, right down to the echo ${CMAKE_PREFIX_PATH} showing up in the terminal, but not in the QT Creator called in the same terminal.

Setup: Kintetic Ubuntu 16.04

My solution was:

  • Follow the steps here: section 4.3
  • New File or Project -> Import Project -> Import Existing Project
  • Select the ~/workspace/src/package folder
  • Add the CMakeList.txt
  • On the side bar, click on Projects, and under Build Environment, add a new CMAKE_PREFIX_PATH variable that is the same as the one pointed to by echo ${CMAKE_PREFIX_PATH}, it should be something like /opt/ros/kinetic.
  • Also had to had the Run Environment Variable ROS_MASTER_URI and set it to http://localhost:11311 or else the package crashes at pos::init

After this, I was able to build, and debug by pointed to the program in the ~/workspace/devel/lib folder.

Hope this helps!

EDIT - Added additional step regarding ROS_MASTER_URI

edit flag offensive delete link more


Thank you very much. That solved it

Anurag VV gravatar image Anurag VV  ( 2018-06-14 13:01:36 -0500 )edit

thank you dude, you saved me. My env is ubuntu18.04, qtcreator 5.14. It seems I just need to tell it the catkin_dir, then it will work.

StevenWong gravatar image StevenWong  ( 2022-11-12 03:52:57 -0500 )edit

answered 2015-08-14 08:00:31 -0500

Simon Schmeisser gravatar image

updated 2017-04-26 03:49:52 -0500

For the "old" way using catkin_make, I first used catkin_init_workspace to set up a workspace containing the packages I need. then run catkin_make to set everything up. Now replace the toplevel /src/CMakeLists.txt (which is a symlink) with the actuall file it links to. Now start qtcreator from a terminal and open that cmakefile. it will run cmake automatically. things should mostly work now in qtcreator, except finding executables. I just start them from a terminal (and use "debug external application" when necessary). If something breaks (ie the error you get), run catkin_make again to fix stuff. This happens from time to time. (Note: since cmake catches it arguments, you don't need to pass anything in qtcreator)

the "new" way is also explained in the wiki you already link. See catkin_tools. Set up a workspace following the tutorial. Build everything using catkin build. Now open the CMakeLists.txt of the project you want to edit in qtcreator. Choose wspath/build/package_name as build dir. Works quite nice.

To be able to execute binaries directly, go to Project -> Execution and duplicate the entry for your executable. the new one should work now, maybe set the working dir to ws/devel/project_name


It all works super nice by now, just follow the documentation here:

edit flag offensive delete link more


Thanks @Simon for the reply! I have updated my original question. Can you please have a look, specially update 2? TIA :)

Naman gravatar image Naman  ( 2015-08-14 13:38:07 -0500 )edit

answered 2016-04-18 09:58:17 -0500

schwarzp93 gravatar image

Hi there :) I'm facing exactly the same problem... Could you solve it by now? Thanks in advance! Philipp

edit flag offensive delete link more


run qtcreator in the terminal and type in correct argument, it should solve your problem

JackChen gravatar image JackChen  ( 2016-05-01 08:45:34 -0500 )edit

Please do not use Answer section to comment. Also please refer to the support guideline, esp. etiquette section.

130s gravatar image 130s  ( 2019-01-15 16:32:00 -0500 )edit

answered 2017-01-30 09:04:27 -0500

superttmm gravatar image

Update2 is the very reason cause the error above.

Probably you have used "sudo qtcreator" to launch qtcreator, which would cause different environment variables in Ubuntu. To work around this "problem" on ubuntu you can do the following in your ~/.bashrc


edit flag offensive delete link more


you should never need to run qtcreator as sudo!

Simon Schmeisser gravatar image Simon Schmeisser  ( 2017-04-26 03:45:46 -0500 )edit

Question Tools



Asked: 2015-08-13 19:16:09 -0500

Seen: 10,677 times

Last updated: Jun 20 '17