Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to code/run programs in a Docker container using CLion?

Tags:

docker

clion

I am a newbie to CLion

I found that CLion has support for Docker. I want to do the following:

(Refer my Linux OS as A.)
(Refer the docker container within A as B.)


The library and environments are set up in B.
The CLion IDE is running in A.
I want to code/debug the program that runs in B using the IDE in A. 

Is this the functionality that CLion supports? I read their documents, but I can't find a way to achieve it

Thanks

like image 734
syko Avatar asked Mar 21 '19 01:03

syko


2 Answers

As of CLion 2021.3 EAP there is a built in Docker Toolchain.

Taken directly from the CLion blog post:

  1. Go to Settings/Preferences | Build, Execution, Deployment | Toolchains.
  2. Add a new toolchain, select Docker type.
  3. Create a docker server and select it in the toolchain settings.
  4. Select one of the available Docker images.

img

Now you can create CMake profiles using this Docker toolchain:

img

Check the full blog post for more details and tips on how to set up and optimize the docker toolchain on different platforms!

like image 50
Increasingly Idiotic Avatar answered Sep 22 '22 20:09

Increasingly Idiotic


It may be not very regular way to do it, but you can actually run a CLion itself inside a docker container. This may be useful if parsing your codebase requires some libraries which you have only in docker but not on your system (I did it to work with ROS). Also you don't need to mess with "remote developement" long loading and syncing time, also debugger works "out of the box".

Example of such setup may be found here.

like image 44
Stanislav Tsepa Avatar answered Sep 19 '22 20:09

Stanislav Tsepa