CLion Quick Start Guide (OLD VERSION)
This Quick Start Guide is designed to introduce the key concepts and help you make a quick start with the IDE.
Step 0. Before you start
What languages does CLion Support?
Support for other languages can also be added via plugins (go toto find out more and set them up).
What platforms can I run CLion on?
CLion is a cross-platform IDE that works on Windows, macOS, and Linux.
Which compilers are supported by the IDE?
CLion supports GCC, Clang and Microsoft Visual C++ compilers.
What do I need to start with CLion? What are the system requirements?
In general, to develop in C/C++ with CLion you need:
GCC/G++ or Clang toolset
On Windows, you need to install the entire environment that includes these tools: MinGW/MinGW-w64, Cygwin or Visual Studio if you are going to use Microsoft Visual C++ compiler (see our Quick Tutorial: Configure CLion on Windows).
For debugging, CLion bundles GDB (on Windows, the bundled GDB is available only for MinGW) and LLDB (on Linux and macOS), so you don’t need to install them separately unless you want to use a custom version instead of the bundled one. Currently, the versions of the bundled debuggers are:
LLDB v 7.0.1
GDB v 8.0.1 for macOS
GDB v 8.2 for Windows
GDB v 8.2 for Linux
For a custom GDB, CLion supports versions 7.8.x-8.2.x
CMake is also supplied with CLion, and you can check the number of the bundled version inunder the CMake field.
For the general system requirements, refer to the Install and Setup guide.
What project formats are supported?
CLion supports CMake, Gradle, and compilation database projects. CMake projects can be created, opened, built, and run. For Gradle, the available actions are opening projects and running gradle tasks. Compilation database projects can be opened and managed as well, plus you can create custom build targets, which employ external tools to build/clean your project, and add Run/Debug configurations associated with custom targets.
Step 1. Open/Create a project
Open an existing project
For CMake projects, use one of the following options:
Select File | Open and locate the project directory. This directory should contain a CMakeLists.txt file.
Select File | Open and point CLion to the top-level CMakeLists.txt file, then choose Open as Project.
Select File | Open and locate the CMakeCache.txt file then choose Open as Project.
To open a compilation database or Gradle project, point CLion ( ) to compile_commands.json or build.gradle or file, and select Open as Project.
Check out a project from Version Control
You can also download sources from a VCS storage or repository. Click Checkout from Version Control on the Welcome screen, or VCS | Checkout from Version Control on the main menu, and select your version control system. Enter the credentials to access the storage, and provide the path to the sources. CLion will clone the repository to a new CMake project.
Create a project from scratch
To start a new CMake project, click New Project or the Welcome screen, select the project type, the root folder location, and the C/C++ language standard. CLion will create a new project and fill in the top-level CMakeLists.txt. A sample project will have the following structure:from the main menu
Step 2. Take a look around
When you launch CLion for the first time, or when there are no opened projects, you see the Welcome screen. It shows the main entry points to create or open a project, get help, and configure the IDE:
When a project is opened, you can see the main window divided into several areas. Let’s take a moment to view the key UI elements:
Project view on the left side displays the project files and directories.
Editor is the area where you can view, write, and edit your code. The editor shows each code file in a separate tab, and also it can be split vertically or horizontally for easier navigation between tabs.
Navigation bar is there for quick access to the run/debug and VSC-related actions.
Left gutter, the vertical stripe to the left of the editor, shows breakpoints and provides a convenient way to navigate through the code structure (for example, jump to a definition or declaration).
Right gutter shows the results of the code analysis performed by CLion as you type. A square sign at the top of the right gutter indicates the overall analysis status for the whole file.
Status bar shows various indicators for the project and the entire IDE: file encoding, line separator, inspection profile , memory indicator, and so on. Also, here you can find the resolve contexts switcher.
Step 3. Customize the environment
Themenu gathers the IDe- and project-level settings that you can customize. A few examples are given below.
Pages under the Editor node help you adjust every aspect of the editor’s behavior, from general settings (like Drag'n'Drop enabling and scrolling configuration) to highlighting colors and code folding options.
Code style can be defined for each language in Editor | Code Style, applicable to a project or the entire IDE depending on the selected Scheme. For C/C++ code, you can configure Naming conventions or use a predefined code style.
CLion is keyboard-centric: nearly all actions possible in the IDE are mapped to keyboard shortcuts or, in case something is missing, you can map actions manually. CLion provides a rich default keymap (explore it in the menu). To customize it, go to where you can choose one of the pre-defined keymaps (Emacs, Visual Studio, Eclipse, NetBeans, Xcode, and others) or create your own.
Step 4. Code with smart assistance
CLion takes care of the routine so that you can focus on the important. Below are some examples of CLion's code insight features for error-free and productive development.
Code completion is a great time-saver, regardless of the type of file you are working with. There are two types of code completion in CLion: basic (Ctrl+Space) and smart (Ctrl+Shift+Space). Basic completion works as you type and completes any symbol instantly. Smart completion analyzes the context and offers more accurate suggestions based on that analysis. For example, it filters the list of functions and variables to match the expression type:
Writing code can be a lot easier and quicker with code generation. The menu (Alt+Insert) will help you with constructor/destructor or getter/setter generation and will suggest overriding (Ctrl+O) or implementing (Ctrl+I) functions:
To generate entire code constructs, use live templates (call or press Ctrl+J). You can explore and extend the list of the ready-to-use templates in .
Also, consider quickly surrounding your code with complete constructs like
#ifdef, and other wrappers, depending on the context. Call or press Ctrl+Alt+T: for example, select an
if statement and you will get
CLion monitors your code as you type and makes smart suggestions called intention actions. Indicated with a yellow light bulb , intention actions enable you to apply automatic changes to the code that is correct (in contrast to code inspections that provide quick-fixes for the code that might be incorrect). As an example, when a constructor misses some parameters or field initializers, CLion suggests an intention for this situation (click a light bulb or press Alt+Enter): Find the full list of the available intentions in .
Step 5. Keep your code neat
CLion monitors your code and tries to keep it accurate and clean. It detects potential errors and problems and suggests quick-fixes for them.
Every time the IDE finds unused code, an endless loop, '=' in a conditional expression, or some other error-prone piece of code that likely require your attention, you’ll see a red light bulb . Click it or press Alt+Enter to apply a fix: Find the complete list of the available inspections in . You can disable/enable inspections and configure their severities (whether you want it to be shown as error or warning) and scopes.
Step 6. Find your way through
CLion comes with a set of navigation features that will help you find your way through any codebase.
To find where a particular symbol is used, use full-scale search via Find Usages (Alt+F7): You also have the option to search only in the current file (Ctrl+F), or within a directory, any arbitrary scope, or the entire project (Ctrl+Shift+F).
To navigate through the code structure, use the following Go-To's:
To search for anything in CLion, be it an item in your codebase, user action, or UI element, press Shift twice and start typing what you are looking for in the Search Everywhere dialog. For example, you can search for an IDE action:
Navigate through the timeline
In CLion, you can easily navigate you to the recent files (Ctrl+E) or recently changed files (Shift+Alt+C). To explore the history of changes, use Back/Forward navigation (Ctrl+Alt+Left/Ctrl+Alt+Right) or jump to the last edit location (Ctrl+Shift+Backspace).
Step 7. Configure the CMake build system
For CMake projects, CLion takes all the information about the project from the CMakeLists.txt files. Every change you make in CMakeLists.txt requires project reload. It can be performed automatically (select the corresponding checkbox in ) or you can call .
To learn more about configuring CMake in CLion, take a look at our CMake Tutorial.
Step 8. Run and debug
For running and debugging your applications, CLion uses Run/Debug Configurations.
To create new configurations, use the predefined templates (for a regular application, remote debug, unit testing, and others). You can find the available templates and edit existing configurations in the Run menu or the configuration switcher:dialog accessible from the
CLion bundles the GDB debugger for macOS, Linux, and Windows (in case of MinGW only), and the LLDB debugger for macOS and Linux. Also, you can use custom GDB on all the platforms.
Debugging almost always includes placing breakpoints: click the left gutter of the line where you want the breakpoint to appear. To start a debug session, select the desired Run/Debug configuration, and press Shift+F9 or click . Then you can follow through the execution step by step (see the available options in the Run menu or the Debug tool window), evaluate an arbitrary expression, add watches and manually set values to the variables:
Step 9. Keep your code under Version Control
CLion integrates with several version control systems: Git (or GitHub), Mercurial, Perforce, and Subversion. To specify credentials and control the settings of a particular VCS, go to .
In the VCS menu, you can find the available commands: for example, to view the changes and commit them, create changelists, and much more. Also, some basic commands are accessible from the Navigation bar above the editor:
In addition to version control, you can use the local history enabled by default. To view it for a file or a folder, call. Here you can review the changes, revert them, or create a patch.
Step 10. That’s it! Go ahead and develop with pleasure!
We hope this brief overview of the CLion essentials will give you a quick start. There are many features that make a developer’s life easier, and your code neater and cleaner. Take these first few steps now, and then dig deeper when you feel the time is right. Enjoy CLion!
With any questions, feel free to ask on the CLion Discussion Forum. Also take a look at our twitter and blog, where you can find news, updates, and useful tips and tricks. And don't hesitate to report any problems to our support team or the CLion issue tracker.