Rosanswers logo

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?

Originally posted by CoffeeKangaroo on ROS Answers with karma: 65 on 2018-03-08

Post score: 2


2 Answers 2


Rosanswers logo

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/clion.sh" %f


CLion is free for students: students click here

Originally posted by CoffeeKangaroo with karma: 65 on 2018-03-08

This answer was ACCEPTED on the original site

Post score: 3

Original comments

Comment by 0xd1ma on 2018-12-19:
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

Comment by 0xd1ma on 2018-12-19:
and for debug, you must select "Executable":

<your workspace path>/devel/lib/<name of your node>

Rosanswers logo

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

Originally posted by pengjiawei with karma: 138 on 2018-03-16

This answer was NOT ACCEPTED on the original site

Post score: 1


Your Answer

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