Installing JetBrain’s CLion on Windows for C/C++ (Beginner's Guide)

Consult Quick start from Jet Brains

Below is some notes taken when setting up the CLion environment that build on the quick-start provided on the website.

What do I need to start with CLion?

CLion is a JetBrains Integrated Development Environment (IDE) – high-powered code editor – for C/C++ development.

System requirements taken from JetBrains

In general to develop in C/C++ with CLion you need:

  • CMake, 2.8.11+ (Check JetBrains guide for updates)
  • GCC/G++/Clang or which in case of Windows means using toolchains: MinGW 3.* or MinGW — w64 3.-4. or Cygwin 1.7.32 (minimum required) up to 2.0.*

What is CMake?

Some pretty good resources/reads:

How is CMake Used, Presentation by the CMake guys, Learning CMake

CMake is confusing for a beginners. In essence, CMake controls the software compilation process in a way that is independent of the OS or development platform.

What does that mean? Developing C/C++ code on different types of computers and environment can be a headache. CMake is a set of tools used to build, test and package a piece of software or program independent of the compiler environment your using. (ie. Eclipse, Visual Studio, JetBrains).

CMake does not  build the software instead it is a “meta-build” tool, that helps organize files for other build systems (in this case CLion)

CMake creates a configuration file (CMakeLists.txt) with information about dependencies, versions and more, that can be passed between environments especially if your working on the same code base.

GCC/G++/Clang or MinGW/CygWin Tool Chains for Windows

MinGW Wiki, CygWin Wiki, GCC/G++ is a compiler.

What is MinGW/Cygwin? A  majority of C Libraries and Packages are written for the Unix environment. Windows is not a Unix Environment. Cygwin and MinGw help get those packages and libraries to the Windows environment. CygWin creates the Unix look and feel on the Windows environment.

GDB: at least 7.8: GDB is a the GNU Debugger tool that can be download as one of the packages during Cygwin setup.

Getting Started

Downloading and Installing CMake

Downloading and installing CMake is pretty simple, just go to the website, download and install by following the recommended guide there or the on Desktop Wizard.

Downloading and Getting Cygwin

Cygwin is not a typical Windows installation. Rather Cygwin downloads and ports related Unix packages to Windows.

How the do I get the GCC Compiler on Cygwin?

The Cygwin guide and installation wizard does not natively download GCC or the related C/C++ libraries for you. Setting Up with wizard will only download the minimal packages for Cygwin to function. But if you’re looking to set up CLion, you’ll need the GCC/G++ Compiler. A great guide to getting the minimal of what you need to run can be found here

1. Open the setup-86_64.exe application:

Follow instructions until you get to installation location:

This is the root directory where Cygwin will be located, usually the recommended C:\ works

Choose where to install LOCAL DOWNLOAD PACKAGES:

This is not the same as root directory, but rather where packages (ie. extra C libraries and tools) you download using Cygwin will be located

Follow the recommended instructions until you get to packages screen:

Once you get to the packages screen, this is where you customize what libraries or tools you will install. From here follow the above guide:

From this window, choose the Cygwin applications to install. For our purposes, you will select certain GNU C/C++ packages.
Click the + sign next to the Devel category to expand it.
You will see a long list of possible packages that can be downloaded. Scroll the list to see more packages.
Pick each of the following packages by clicking its corresponding “Skip” marker.
gcc-core : C compiler subpackage
gcc-g++ : C++ subpackage
libgcc1 : C runtime library
gdb : The GNU Debugger
make : The GNU version of the ‘make’ utility
Note: If a package has not been previously installed, then clicking the “Skip” marker selects the package and shows its version number.
Click the — sign next to the Devel category to close it.
Click the + sign next to the Libs category to expand it.
Pick the following package by clicking its corresponding “Skip” marker.
libmpfr4 : A library for multiple-precision floating-point arithmetic with exact rounding
(Note: On some systems this may already be selected. If so, you may ignore this step.)
Click the — sign next to the Libs category to close it.
In addition to the specific packages you picked, the setup program automatically selects other packages that are needed to build a working Cygwin environment.
Click [Next >].

Continue and wait for download.


Once you’ve got all the requirements set up above, you can boot up CLion and try testing out. Open CLion and hit create new project Give the project a name and directory

By default the CMakeList.txt file is for C++, but you can change it to C. (Make sure you only have one)

# CMakeLists.txt
# C++ Development
cmake_minimum_required(VERSION 3.5)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(dbsg ${SOURCE_FILES})

# C Development
cmake_minimum_required(VERSION 3.5)
set(SOURCE_FILES program1.c)
add_executable(dbsg ${SOURCE_FILES})

Before you can compile, build and run you need to tell CLion where it can find your environment and compiler. Open up Settings by clicking File | Settings. With the Settings menu open navigate to Build, Execution, Deployment | Toolchains. In the environment section select Cygwin (or MinGW if your using it) and click the ellipsis (…) button. Locate your Cygwin Root folder in your file system and select it.

CLion will now test to and you should be set.

Kind thanks to Ian Panelo for the cover image.