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

Qtcreator with Catkin

asked 2013-07-12 19:46:10 -0500

Calder gravatar image

updated 2014-01-28 17:17:15 -0500

ngrennan gravatar image

I've been using Qtcreator for a long time with rosbuild packages, where it puts the executables in the package/bin/ directory just like rosmake. Using Qtcreator with catkin packages, I can edit and compile the code just fine, but since the binaries aren't put in the catkin_workspace/devel/ path, I still have to run catkin_make by hand for the binaries to be usable. Is there a solution to this that lets Qtcreator put the libraries and executables in the correct location?

edit retag flag offensive close merge delete

Comments

In catkin we support out of source builds, which is something that QtCreator usually does by default. Why do you think that the bin and lib folders need to be in the package directory?

William gravatar image William  ( 2013-07-12 19:50:01 -0500 )edit
1

I didn't say that - I'm well aware that catkin puts them outside the package directory. As I noted, the problem is that qtcreator is putting them in the wrong place relative to where catkin_make puts them, which means that the executables aren't used properly.

Calder gravatar image Calder  ( 2013-07-12 19:53:11 -0500 )edit

I see what you are asking now.

William gravatar image William  ( 2013-07-12 19:55:02 -0500 )edit

5 Answers

Sort by » oldest newest most voted
9

answered 2013-07-12 20:07:27 -0500

William gravatar image

The problem is that caktin_make calls cmake with -DCATKIN_DEVEL_PREFIX=/path/to/catkin_workspace/devel, but QtCreator is just calling cmake without any arguments. This causes catkin to place the develspace in the default location which is inside the build folder. You can probably add arguments to cmake in the QtCreator settings somewhere.

What I would do is build your workspace once with catkin_make, then open the CMakeLists.txt in the src folder with QtCreator and point QtCreator to the build folder created by catkin_make, then it should inherit all of the CMake settings catkin_make passed along.

edit flag offensive delete link more

Comments

That solves the problem. It's not the prettiest solution to put all the packages in one Qtcreator project, but I guess it fits the usage model of catkin better.

Calder gravatar image Calder  ( 2013-07-12 20:29:16 -0500 )edit

I think you can also point QtCreator to the CMakeLists.txt for a single package and then point it at the build/package_name folder for the build space, but I am not sure if that will work.

William gravatar image William  ( 2013-07-12 20:30:44 -0500 )edit

I believe I've tried that, and it doesn't work. Qtcreator ends up making a miniature copy of the devel/ directory structure inside build/package_name directory.

Calder gravatar image Calder  ( 2013-07-12 20:32:54 -0500 )edit

I solved the problem by adding CMAKE_PREFIX_PATH + CATKIN_INSTALL_PREFIX + CATKIN_DEVEL_PREFIX inside the "Cmake Configuration" of the QtCreator KIT. Please note that i initially wrote the cmake-prefix using the standard "linux" colon (:) punctuation mark to separate the folders like /pathA:/pathB

Augusto Luis Ballardini gravatar image Augusto Luis Ballardini  ( 2017-04-12 17:49:11 -0500 )edit

but inside the QtCreator you need to separate the two paths using the semi-colon ... imho there's a little mess there, since the Cmake path prefix loaded from the environment have the (:) ... maybe this is the reason why it does not automagically works ? CMAKE_PREFIX_PATH is also set in the env

Augusto Luis Ballardini gravatar image Augusto Luis Ballardini  ( 2017-04-12 17:51:51 -0500 )edit
4

answered 2015-05-27 16:01:12 -0500

Mike Hosmar gravatar image

I would like to add for anyone looking at this question from now on that now you can compile and add one package from your catkin workspace as a project in Qt. With the new catkin_tools package there is no top level cmake file and therefore no symlink issue.

  • To setup your project you first need the catkin tools package. I installed this with apt-get as follows sudo apt-get install python-catkin-tools There are some differences between the tools package and the catkin_make your used to (now its catkin build) but ill leave it to you to read the docs.

  • You will need to reinitialize your catkin workspace. I found that you can just reuse an existing workspace but I I'm not sure if it will cause me issues down the road. First clean your workspace ie delete build and devel. Then run catkin init and it should inherit the configuration from the original workspace. You should see that it is Extending /opt/ros/indigo or similar. If not you'll have to add it. (See:Workspace Chaining)

That should be it for catkin_tools. Now you can build with catkin build instead of catkin_make or clean with catkin clean -a

The rest of the steps are almost identical to @Jose Luis Blanco except that when adding the project add the CMakeLists.txt of the package its self and set the build folder to ws/build/your_package instead of ws/build as before. (See: ROS IDEs)

Also there is another tutorial out there similar to Jose's but has the build settings as follows ../src -DCMAKE_INSTALL_PREFIX=../install -DCATKIN_DEVEL_PREFIX=../devel if you have that remember to remove the ../src

edit flag offensive delete link more

Comments

This really works the best and should be upvoted some more. Don't forget the section about modifing qtcreator.desktop at ROS wiki: ROS IDEs

Simon Schmeisser gravatar image Simon Schmeisser  ( 2016-04-29 07:42:47 -0500 )edit
2

answered 2014-12-19 06:58:32 -0500

I wrote a short tutorial on this (and also on using CodeBlocks, but QtCreator seems much more responsive).

In short:

  • Replace the src/CMakeLists.txt symlink with an actual file
  • Open qtcreator from the console.
  • File -> “Open File or project…“, then pick ~/catkin_ws/src/CMakeLists.txt and set the build dir to ~/catkin_ws/build/
  • Select the tab Projects -> Build Settings and add these CMake arguments:

    -DCMAKE_INSTALL_PREFIX=../install -DCATKIN_DEVEL_PREFIX=../devel

  • Close & reopen qtcreator (from a console where you sourced ROS setup.bash!) to make sure it generates the project.

  • Ready to go!
edit flag offensive delete link more

Comments

1

I had problems with the symlink, thanks. Instead of launching from a terminal, you can create qtcreator.desktop with the following content and drag it to your launch bar: http://pastebin.com/uw0cxntD

brice rebsamen gravatar image brice rebsamen  ( 2015-02-03 18:39:25 -0500 )edit

If I follow these steps, executables are not found automatically by QtCreator, the other answer (running catkin_make first) works quite fine for me

Simon Schmeisser gravatar image Simon Schmeisser  ( 2015-03-04 06:29:24 -0500 )edit
0

answered 2015-12-17 15:28:59 -0500

Farid gravatar image

--------------------- How to open a catkin package in QT creator --------------------

  1. create the pkg

catkin_create_pkg <package name=""> [depend 1] [depend 2] [depend 3]

  1. catkin_make --source .

to make build, devel and CMakeLists.txt file

  1. source ./devel/setup.bash

    1. remove the CMakeLists.txt in the folder u have catkin package (not the one inside the package)
  2. go to opt/ros/hydro/share/catkin/cmake

copy "toplevel.cmake" to the folder u have package

  1. Rename it to "CMakeLists.txt"

copy the following lines @ the end of this file:

#Add all files in subdirectories of the project in

a dummy_target so qtcreator have access to all files

FILE(GLOB children ${CMAKE_SOURCE_DIR}/) FOREACH(child ${children}) IF(IS_DIRECTORY ${child}) file(GLOB_RECURSE dir_files "${child}/") LIST(APPEND extra_files ${dir_files}) ENDIF() ENDFOREACH()

add_custom_target(dummy_${PROJECT_NAME} SOURCES ${extra_files})

  1. open a QT (go to QT folder and run the file) from a terminal that u've sourced the setup.bash file

  2. In QT creator ... open project -> go to the folder of a package -> open "CMakeLists.txt"

  3. Build Location: choose "build" folder from the folder of a package

  4. Run Cmake : -DCATKIN_DEVEL_PREFIX=../devel -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=Debug

  5. 12.
edit flag offensive delete link more
0

answered 2017-05-02 22:19:45 -0500

sai gravatar image

Very similar to what @Jose Luis Blanco had mentioned. A simple tutorial is here which worked for me

http://myzharbot.robot-home.it/blog/s...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-07-12 19:46:10 -0500

Seen: 17,725 times

Last updated: May 02 '17