CUEH

Development Environment Guides

Installing Jetbrains CLion

Installing Jetbrains CLion

As part of the programming module you study on the course, you are required to interact with the C++ programming language. This interaction will be undertaken using an Integrated Development Environment (IDE), which will be installed within the Windows operating system.

In this guide, you shall be taken through the journey of installing the Jetbrains CLion IDE and how it will interact with the Linux (Debian-based) operating system for any module that may make use of the IDE.

Preliminary Information

There is an expectation that you will have a JetBrains educational license. The IDE that is recommended by this course, is the JetBrains suite of applications. The JetBrains suite is payware, and as such they do not come for free. However, as students at this university you are able to obtain a free educational license. To obtain your free license, follow the instructions at the following URL:

JetBrains Educational License

Downloading and Installing the Jetbrains CLion IDE

The JetBrains CLion application is an IDE and is relatively useful for the course you are studying as it provides a means to develop applications for the C++ programming language.

Downloading the IDE is relatively straight forward, you can use a single command. Before you can execute the command, you will need to open the Terminal window. To do this, you can either use the keyboard shortcut: Ctrl + Alt + T or search for Terminal in the Application screen as shown in Figure 1.

Figure 1

Figure 1. Searching for Terminal in the Application Screen.

In the terminal window, you can proceed with downloading the IDE file by entering the following command:

$ wget https://download.jetbrains.com/cpp/CLion-2023.1.1.tar.gz -O clion.tar.gz

This will begin the process of downloading the CLion installation files from the JetBrains server. The outcome of this command should be similar to that of the terminal window shown in Figure 2.

Figure 2

Figure 2. Downloading the CLion Installation Files from JetBrains.

Once the files have been downloaded, they are stored in a compressed archive (.tar.gz). This will require uncompressing to an appropriate area of your Linux system. Uncompressing an archive can be achieved using the tar command. However, before uncompressing the archive, you are required to decide which directory to uncompress the archive to. For the purpose of this guide, the archive will be uncompressed to the /opt directory.

The opt directory is a root-privileged only directory, as such you are required to use the sudo command to escalate privileges on the machine. To uncompress the archive to the opt directory, the following command can be used:

$ sudo tar xvf clion.tar.gz -C /opt

The -C flag is used to denote which directory you would like the contents of the compressed archived to be extracted to. When the command is executed, you will be asked for the password of your user account. In this instance, you will want to enter the password you would normally use to log in to the system. Note, that when you enter the password it may come across as if you are not entering anything; this is normal, and continue entering the password as usual and then push the Enter key. This will begin extracting the contents of the archive, as shown in Figure 3.

Figure 3

Figure 3. Extracting the CLion Archive to the `opt` Directory.

To confirm whether the files have been extracted to the opt directory, the following command can be executed in the terminal window:

$ ls /opt

The outcome of this command should list the folders and files that are located in the /opt directory. In this instance, you should see something similar to the output shown in Figure 4.

Figure 4

Figure 4. The contents of the `opt` directory.

Before you can begin using the CLion IDE, there are a couple of things we need to do:

  1. Rename the CLion directory in /opt.
  2. Add a shortcut to the CLion binary to the Application screen.

Renaming the CLion Directory

The first step is relatively straight forward; to rename a directory you can simply move the contents of the folder to another folder with the new name. This can be achieved with using the mv command:

$ sudo mv /opt/clion-2023.1.1 /opt/clion

The command above is essentially renaming the clion-2023.1.1 directory to clion, omitting the version number 2023.1.1. Remember, that the sudo command is also being used as the opt directory is a root-privileged only directory, thus any changes made to this directory needs root/administrator access.

To confirm whether the changes have been successfully applied, you can list the contents of the /opt directory using the ls command:

$ ls /opt

The outcome from this command can be seen in Figure 5, and you can observe that the old clion-2023.1.1 directory has been renamed to clion.

Figure 5

Figure 5. The contents of the `opt` directory with the `clion` directory renamed.

Adding the CLion Binary to the Application Screen

The next step is to add the CLion binary to the Application screen so it can be easily accessible for you, instead of having to run a command when you want to access the IDE. To achieve this, a file needs to be created in the directory /usr/share/applications. Once again, this directory requires root-privileges and as such the sudo command will be required. In this directory, you are required to create a file called CLion.desktop and this can be achieved using the nano command:

$ sudo nano /usr/share/applications/CLion.desktop

The nano command will open a text-editor in the terminal window, in which you will be able to type (or paste) content into the newly created file CLion.desktop. The contents of this file should be the following:

[Desktop Entry]
Type=Application
Terminal=false
Name=CLion
Icon=/opt/clion/bin/clion.svg
Exec=/opt/clion/bin/clion.sh

The terminal window should look similar to that of the one shown in Figure 6.

Figure 6

Figure 5. The contents of the `CLion.desktop` file.

To save the contents of the file, press the following key combination on the keyboard, Ctrl + X. This will then create a shortcut to the CLion binary on the Application screen. You can now search for the IDE in the Applicationscreen, by clicking on the grid of dots in the bottom left-hand corner and searching for CLion, as shown in Figure 7.

Figure 7

Figure 3. Searching for JetBrains CLion in the Application screen.

To open the IDE click on the icon in the Application screen. Before the main IDE window is opened, the CLion user agreement will be shown, click on the checkbox to agree to the user agreement and click the Continue button. Another window will be presented, asking whether you want to share your data, click on the Don't Send button.

Once the relevant user agreements and data sharing processes have been completed the IntelliJ IDEA application will begin to load.

Activation of the IDE

On the first instance of following this guide, and the IDE has been installed and loaded, it will ask for you to activate your software. In order to do this, you need to click on the Log In to Jetbrains Account... button. This will open an internet browser window, whereby you will need to sign-in with your JetBrains account you created earlier.

Once you have logged in to your account, the internet browser will close automatically, and you should now see an Activate button appear. Click on this button and your IDE will be activated, and you should be presented with an application window similar to the one shown in Figure 8.

Figure 8

Figure 4. The Jetbrains CLion application.

Creating an Empty Project

In this section of the guide, we shall begin the process of creating a new project. Once the IDE has loaded, you will be met with a splash screen similar to the one shown in Figure 8. On the splash screen, you will see a button labelled New Project, click on this button. A new window will pop up with a variety of different options, as shown in Figure 9.

Figure 9

Figure 9. Creating an empty project using the CLion IDE.

You can see in the new window, I have selected the C++ Executable option on the left hand-side. Once this item has been selected, you will then be asked to provide a name of the project and the location where you would like to save the project folder. In this instance, I have chosen to call my project empty_project and the location has stayed as the default location: /home/ian/CLionProjects.

Notice that the C++ language standard selected is C++20. This is the C++ standard that is taught on this course. Once you have populated the details, click on the button labelled Create. This will begin the process of creating a new C++ project. Once the project has been created, a window will pop up to show the detected C++ compiler, and other necessary compilers that are required for the CLion IDE, similar to the screen shown in Figure 10.

Figure 10

Figure 10. Automatic detection of the system compilers in the CLion IDE.

You will need to ensure that the Build Tool and C++ Compiler have both been detected in order for you to begin working on your C++ activities/assignments. If they show as detected on the pop-up window, you can click on the OK button.

Conclusion

That is the end of this guide on setting up the JetBrains CLion IDE and configuring it to interact with the Linux operating system. If you have followed all the necessary steps correctly, you should have a fully functional IDE which will enable you to complete any necessary programming-based activities you will participate with on this course.

Mistakes or Problems?

If you have spotted any errors or issues within this tutorial, you can e-mail Dr Ian Cornelius. Ensure to include in your message a description of the error/issue and a possible resolution. Also do not forget to include a URL to the page with the issue/error.