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
-DCMAKE_INSTALL_PREFIX=/home/sharath/catkin_ws/install
-DCATKIN_DEVEL_PREFIX=/home/sharath/catkin_ws/devel
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):
execute_process(/usr/bin/python
"/home/sharath/catkin_ws/build/catkin_generated/generate_cached_setup.py")
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 CMAKE_PREFIX_PATH:
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- 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,
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.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 ?
- 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.
Update:
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 CMAKE_PREFIX_PATH:
-- 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:
- in a terminal make sure cmake works and all path are set
- start qtcreator from this terminal
- see if it works
Comment by yin on 2016-11-27:
hello, I also encounter this problem, have you solved the problem?