Install Clion under Ubuntu

foreword

CLion is a C++ integrated development environment (IDE) developed by JetBrains, which has many powerful functions, such as code completion, debugger, version control and so on. CLion itself is paid software, but if you are a student, you can apply for free use .
Test installation environment: Ubuntu18, Ubuntu22

1. Clion installation

(1) Official download and installation package

Official download and installation package

image-20230409165524190

(2) Unzip the installation package

gzip -d CLion-2023.1.1.tar.gz
tar -xvf CLion-2023.1.1.tar

(3) Replace the jbr folder

When jetbrains family bucket is used in Ubuntu, there will be a problem that the input method does not follow. You need to replace the jbr folder in the source file to solve it

First download the jbr file recompiled by others on github: (If the Clion version is newer, the downloaded jbr version should also be newer. I use the Clion2023 version, and the downloaded jbr version is release 17.0.6 )

image-20230409170019866

After downloading, unzip and rename to jbr:

image-20230409170135438

Then replace to the jbr folder in the Clion installation package:

image-20230409170207386

(4) Copy the installation package \optinto

sudo cp -rf CLion-2023.1.1 /opt

(5) Execute the installer

cd /opt/CLion-2023.1.1/bin
sh clion.sh

(6) Create a desktop shortcut key
(if the initial installation is complete, it should be an English interface, the picture below shows that I installed the Chinese plug-in)
image-20230409170428600

(7) Download the Chinese version of the plug-in

Download the Chinese package plug-in in the plugs option in the settings of clion:

image-20230409170521043

2.Clion configuration project

(1) Compiler configuration

image-20230409170909759

(2) cmake configuration

image-20230409171021114

(3) How does clion run the project

clion compiles and runs projects through cmake, and cmake compiles and runs projects can be divided into three steps:

One is cmake <source tree>, for example cmake .., used to generate project files project files;

The second is that cmake --build .the function of build is to adaptively build projects (or compile and link projects) based on the compiler of the current system. When you know that the compiler of your system is Unix Makefiles, you can also use it directly to build the project make;

The third is to run the compiled executable file, such as ./main;

Returning to clion, the first two steps are actually configuring the path of the compiler and the command line parameters of cmake. After configuration, running a project is actually divided into three steps like cmake:

First cmake .., when clion opens the project, it will be automatically generated cmake ... The default is to generate it in cmake-build-debugthe folder. Of course, you can also manually right-click the project and select it , but you need it after reload cmake projectyou modify the file ;CMakeLists.txtreload cmake project

The second is cmake --build .that it corresponds to the function of the build button in clion. If an error is reported: Error: could not load cache, then you have not completed step 1 reload cmake project;

image-20230409195358857

The third is ./main, the run button in clion, in fact, the run button will complete step 2 and step 3 at the same time, that is, run will build first, and then run the executable file;

image-20230409195531739

Guess you like

Origin blog.csdn.net/caiqidong321/article/details/130126200