Ask Your Question

Setup CLion with ROS

asked 2018-03-08 03:38:45 -0600

Eugen gravatar image

I have some troubles setting up CLion to work properly with ROS (kinteic).

CLion does not recognize my workspace properly thus the IDEs features do not work.

How to setup CLion with ROS?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-03-08 03:44:13 -0600

Eugen gravatar image

updated 2019-01-07 07:40:00 -0600

JetBrains now offers their own instructions on how to setup ROS with CLion: see here

CLion is a nice tool but for me it did not work out of the box as claimed sometimes. This should be a beginner (primary targeting students) friendly guide on how to use CLion with ROS.

How to setup CLion with ROS (kinetic) [as simple as possible]:

*Note: this how to is tested on Ubuntu 16.04 with CLion 2017.1.3 and 2017.3.2, the process might be different with other versions.

I recommend to check if catkin_make runs properly in your workspace before you start with this guide. In this way you know CLion is the problem, not ROS.*

  • Start CLion from the terminal to ensure everything is sourced properly. You can alternatively edit the .desktop file, see below).
  • Click "Import Project from Sources"
  • Select the <your workspace path>/src folder in your workspace
  • Click "Open Project" - code editor should open
  • Go to "File" - "Settings" - "Build, Execution, Deployment" - "CMake"
  • Set the generation Path to <your workspace path>/build and apply
  • Finally you should right-click on your top level CMakeList.txt file in CLion and select "Reload CMake Project"

CLion should work properly now.

Always start CLion from terminal unless you changed the .desktop file!

Rename Project/Workspace:

At the restart of CLion the Project will be shown at the recent projects with the name "src". The project/workspace can be renamed by renaming the <your workspace path>/src/.idea/src.iml to <your workspace name>.iml and changing the path to it in <your workspace path>/src/.idea/modules.xml and by creating a file <your workspace path>/src/.idea/.name (containging only a name for the project).

cd src/.idea
mv src.iml $NEW_NAME.iml
sed -i -e "s/src/$NEW_NAME/g" modules.xml 
printf "$NEW_NAME" >  .name

If CLion shows you the info "This file does not belong to any project target" right-click the includes folder an click "Mark Directory as" and select "Project Sources and Headers".

Setup debugging:

  • Go to "Run" - "Edit Configurations" and click the add button
  • Set a name
  • Select a "Target" and the according "Executable", keep the "Configuration" on Debug and apply

Now you can run and debug from the terminal. This does not work with .launch files

Highlighting in .launch files:

CLion does not recognize .launch files as XML files by default.

  • Go to "File" - "Settings" - "Editor" - "File Types"
  • Search for XML in the recognized files list
  • add *.launch

.launch files should now have proper highlighting and autocomplete

Change the .desktop file:

  • Go to <your home folder>/.local/share/applications
  • change the according line the .desktop file for your CLion version to:

    Exec=bash -i -c "<clion installation path>/bin/" %f


CLion is free for students: students click here

edit flag offensive delete link more


Set the generation Path to:

<your workspace path>/build

for me, it works if:

<your workspace path>/build/<name of your node>

and it is necessary to clear catkin workspace and rebuild pkg from the command line

0xd1ma gravatar image 0xd1ma  ( 2018-12-19 03:55:21 -0600 )edit

and for debug, you must select "Executable":

<your workspace path>/devel/lib/<name of your node>
0xd1ma gravatar image 0xd1ma  ( 2018-12-19 04:02:50 -0600 )edit

answered 2018-03-16 01:12:46 -0600

by the way . If you don't wanna build all projects in directory <your workspace path>/src , you can add -DCATKIN_WHITELIST_PACKAGES="your_pkg1_name;your_pkg2_name" in CMake options that located in File->Settings->Build,Execution,Deployment->CMake

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2018-03-08 03:38:45 -0600

Seen: 4,723 times

Last updated: Jan 07 '19