Rosanswers logo

Hi all,

I am trying to open a ros package in Qt Creator following http://wiki.ros.org/IDEs . 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/generate_cached_setup.py", 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 ?

  1. 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 in ~/catkin_ws, it cannot find the command. So, I have to do source /opt/ros/indigo/setup.bash and then catkin_make works and everything is back to normal I guess. Now, when I again run cmake from Qtcreator, the cycle repeats. I am not able to figure out why is this happening. Why am I getting that error when I run cmake in Qtcreator and why do I have to source the setup.bash after that? Does anyone have any idea about it?

Update 2:
I think the problem is when I do cmake in qtCreator, it is not able to find CMAKE_PREFIX_PATH. It is just empty :

 -- Using CATKIN_DEVEL_PREFIX: /home/sharath/catkin_ws/devel
    -- Using PYTHON_EXECUTABLE: /usr/bin/python

Whereas when I do catkin_make in the catkin_ws, it is able to find CMAKE_PREFIX_PATH :

-- Using CATKIN_DEVEL_PREFIX: /home/sharath/catkin_ws/devel
 -- Using CMAKE_PREFIX_PATH: /home/sharath/catkin_ws/devel:/opt/ros/indigo
 -- Using PYTHON_EXECUTABLE: /usr/bin/python

Can someone tell me why QtCreator is not able to get the CMAKE_PREFIX_PATH although it is properly set and I can see in the terminal using echo $CMAKE_PREFIX_PATH?

Please let me know if you need more information from me.

Thanks in advance.
Naman Kumar

Originally posted by Naman on ROS Answers with karma: 1464 on 2015-08-13

Post score: 4

Original comments

Comment by Simon Schmeisser on 2015-08-17:
how do you open qtcreator?

Comment by igor on 2015-10-22:
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.app/Contents/MacOS/Qt\ Creator) is not starting cmake in the same environment with the same environment variables, as the one from which qtcreator itself was started

Comment by Clément Z on 2016-02-14:
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

Comment by Simon Schmeisser on 2016-02-16:
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

Comment by yin on 2016-11-27:
hello, I also encounter this problem, have you solved the problem?


3 Answers 3


Rosanswers logo

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

Originally posted by JackChen with karma: 46 on 2016-05-01

This answer was ACCEPTED on the original site

Post score: 3

Original comments

Comment by Farid on 2016-08-26:
It fucking works dude!


Rosanswers logo

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: http://wiki.ros.org/IDEs#QtCreator

Originally posted by Simon Schmeisser with karma: 229 on 2015-08-14

This answer was NOT ACCEPTED on the original site

Post score: 1

Original comments

Comment by Naman on 2015-08-14:
Thanks @Simon for the reply! I have updated my original question. Can you please have a look, specially update 2? TIA :)


Rosanswers logo


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: http://wiki.ros.org/IDEs#QtCreator 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

Originally posted by amcelroy with karma: 11 on 2017-06-20

This answer was NOT ACCEPTED on the original site

Post score: 1

Original comments

Comment by Anurag VV on 2018-06-14:
Thank you very much. That solved it

Comment by StevenWong on 2022-11-12:
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.


Your Answer

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