Download/Install/Test the CLion IDE
CLion is an Integrated Development Environment (IDE) that uses the Clang C++ compiler to develop/test C++ programs. It occupies about .6 GB on disk.
Before installing CLion in this handout, you should have already downloaded and installed the Clang C++ compiler (if you haven't, go back and do so).
You may want to print these instructions before proceeding, so that you can refer to them while downloading and installing CLion. Or, just keep this document in your browser. You should read each step completely, before performing the action that it describes.
This document shows the installation of CLion version 2016.2.2; I installed this version originally, but I am now using verson 2016.3.1. You should install the latest version to be compatible with how CLion is used in this document.
In this section you will register for a free copy of CLion online.
When run, the following JetBrains Products for Learning screen should appear. Fill it in as shown, but with your Name and Email address (not mine).
Click the APPLY FOR FREE PRODUCTS button.
The following screen may appear.
If it appears, click the checkbox.
A Thank You! screen will appear, indicating that Jet Brains is sending you a Confirm Request email.
Hi,You've received this email because your email address was
used for registering/updating a JetBrains Educational Pack.Please follow this link to confirm your intention:
Confirm Request
Yours truly,
JetBrains Team
https://www.jetbrains.com
The Drive to Develop
Dear <Your first name>Congratulations! Your JetBrains Student License is confirmed.
To activate your license, use the following link:
Activate Educational LicenseAfter accepting the License Agreement, you will be asked
to sign up for a Student JetBrains Account. You will use
this account to sign in to JetBrains product(s) whenever
you use them.Happy coding!
Yours truly,
JetBrains Sales Team
https://www.jetbrains.com
The following JetBrains Products for Learning screen should appear.
The following JetBrains Product Pack for Students screen should appear (I have blacked-out my License ID).
Write down the License ID for future reference.
In this section you will download and begin installing CLion for use with the Clang C++ compiler.
When run, the following Download CLion screen should appear (ensure the Oval surrounds the operating system you are on).
Click the Download button to download the executable file named CLion-2016.2.2.dmg, which when run will install the 64-bit version of CLion. Its icon will appear on your screen as follows.
Save this file for future use, in case you need to reinstall it (or just leave it in the downloads folder).
When run, the following CLion pop-up window should appear on your screen.
When run, the following Copy pop-up window should appear on your screen.
In a few seconds, the progress bar should complete and the window should disappear Terminate the CLion window that remains.
In this section you will finish installing CLion and then create, build, and run a trivial CLion project/program (including editing it and seeing how syntax errors are reported). It will also discuss some useful features in the CLion IDE.
The following pop-up window should appear on your screen.
The following CLion Privacy Policy Agreement pop-up window should appear on your screen.
The following CLion License Activation pop-up window should appear on your screen.
The following Customize CLion UI Themes pop-up window should appear on your screen.
Ensure the Default radio button is pressed.
The following Customize CLion pop-up window should appear on your screen.
The following Customize CLion pop-up window should appear on your screen.
The following Customize CLion pop-up window should appear on your screen.
The following splash should appear on your screen.
Eventually CLion loads and the following Welcome to CLion pop-up window should appear on your screen (updated to the version you downloaded; this screen appears only the first time you start CLion).
The following New Project pop-up window should appear on your screen.
In the Location textbox, at the end of the path, replace untititled with trivialtest; leave the C++ Executable and C++11 selected.
If a Tip of the Day pop-up window appears, click it Close button.
The following CLion project window should appear on your screen.
Note that the right pane lists the tabs CMakeLists.txt (which contains the project's make code) and main.cpp (which is shown and contains a trivial C++ program).
In this window, I right-clicked in the gray area between the project and the driver.cpp panes and selected Show Line Numbers.
It useful to click the triangle to the left of trivialtest in the Project/left pane.
Every project will contain a cmake-build-debug folder, which will ultimately contain the compiled code (executable) for the project. Later, we will see how to put data files in that folder; the executable uses that folder by default for reading/writing files.
The following CLion project window should appear on your screen.
The results of the build appear in the Message Build pane. This trivialtest C++ program has now been compiled and linked successfully; either could have dispayed errors in the Message Build pane, which would have to be corrected before the program could be run.
The following Edit Configuration pop-up window should appear on your screen.
For the Target dropdown, select trivialtest as shown. The Executable dropdown will change to trivialtest automatically.
The following CLion project window should appear on your screen.
The results of running the program print in the Run pane.
The following CLion project window should appear on your screen.
The results of rerunning the program appear in the Run pane.
The following CLion project window should appear on your screen.
To try to rebuild and rerun this code (it will fail), click the (Run icon) again.
The following CLion project window should appear on your screen.
The failed results of attempting to rebuild the program appear in the Messages Build pane; here I have repositioned the separation between the mail.cpp and Message Build panes to show the entire program and all the errors allow all errors to appear.
In this section you will learn more about CLion, by downloading the course libraries and then downloading/building/running a CLion project that contains various programs that use these libraries.
Generally, whenever you download CLion projects, you will unzip them and then copy their folders into the folder that ClionProjects shortcuts.
The following pop-up window should appear on your screen.
You may need to scroll this window to select the CLionProjects folder to make it appear as shown above. The Users folder should contain a folder with your name (richardepattis for me); it should contain a folder with the ClionProjects folder; it should contain the four folders courselib, gtestlib, test_all_data_types, and trivialtest.
Click on the test_all_data_types folder, so that it is highlighted.
The following Open Project window should appear on your screen.
The following CLion project window should appear on your screen.
The following CLion project window should appear on your screen.
If you press command-/ again, it will comment the lines; so this command really means toggle-comment on the selected lines. Before continuing ensure lines 30-35 are uncommented.
The following CLion project window should appear on your screen.
First it will show the Message Build pane; it should be successful, so it should next show the Run pane.
Experiment with this driver by entering commands (and their arguments, when prompted) to better understand the set data type. You can enter the q command to terminate the driver, or you can click the (Stop icon) on the left of the Run pane to terminate the driver. After terminating the driver, click the (Close icon) left of the Run pane to close/remove the Run pane.
I suggest that you try terminating the driver with a q command; then, rerun the program and terminate it with the Stop icon.
The following Finder window should appear on your screen.
Whenever you create a project, a cmake-build-debug folder will appear in its project folder. We have built two projects in this handout: test_all_data_types and trivialtest; each has its own cmake-build-debug folder.
Experiment with this driver by entering commands (and their arguments, when prompted); it runs as it did in the CLion Run Pane. Note that when you enter the q command the program terminates and the Terminal window stops. For example, if you find the trivialtest.exe file and run it by double-clicking this file, its MS-DOS windo will run and then immediately disappear.
For a program that produces lots of output it is often faster to run the program in a Terminal window, rather than in CLion.
Then, run the program (either in the CLion Run pane or a Terminal window; try doing it in both places) and issue the lf command (load from file); when prompted for the file name, just press the Enter key to choose the default (loadset.txt).
When running using the CLion Run pane, the following CLion project window should appear on your screen.
IMPORTANT: If a program reads data files, the root folder for the specifying the files is the folder in which the executable file appears. It is simplest to copy all the data files into this folder. An alternative would be to leave the files in the input files folder, copy the entire folder, and then refer to these file names like input files/loadset.txt.
In the test_all_data_types project folder, the driver.cpp file has many main functions: we uncommented one (in step 6) to allow us to run the Set driver. If more than one main function is uncommented, attempting to build the code will result in the compiler specifying a redefinition of 'main' error.
The test_all_data_types project folder also contains many .cpp files (their names all start with test) that each contain one main function (each is a Googletest for one data type). If more than one file contains a main function, attempting to build the code will result in the linker specifying a multiple definition of 'main' error.
To switch this project from running the Set driver to the Set Googletest
Click the (Run icon). When prompted enter the three lines of information shown.
The following CLion project window should appear on your screen.
The bottom should show
We are now at the end of this handout. You will not need to repeat the first two sections during the course, but you will frequently download project folders and use them as demonstrated in section 3.