Prepare Your Development Environment
To get started C++ programming you should know something about C++ language and building tools. Please head on over to IsoCpp to get a hang of some ideas and piece of information on C++ infrastructure, recommended books, useful links, draft documents.
On the bumpy road to Cmakeland
To start coding together with me you need:
- Cmake
- One C++ compiler or more
- Ninja build-automation tool
- Graphviz
- Your favourite IDE with CMAKE support or the preferable text editor
The minimum CMake version 3.8 is required for this tutorial. Run quickly to your computer grab Cmake for your platform and install it. Download Ninja and plant it in your platform.
There are many good free C++ compilers you can use:
- Clang
- Gnu Compiler Collection
- Visual C++ 2017 Community 1
- Embarcadero
- Oracle Solaris Studio C++ Compiler
- IBM XL C/C++ Compiler.
Install a compiler toolchain you prefer. Also there are many IDEs supporting a cmake project development. On:
- Linux, Android, IOS (a place for your work)
- Windows, as your integrated development environment IDE you can use Visual Studio 2017, VS Code, Clion, Code::Block or QT Creator which provide CMake support.
My development environment
Here you find some hints concerning the installation process of individual elements of my developer’s tools. See here for more details.
Operating System
Windows 10 1809 64-bit
CMake + Ninja
Run cmake installer.
During a cmake installation remember to tick any “add to path” option.
Be quick on the draw!
To “install” ninja just copy a binary ninja.exe to Cmake/bin installation folder.
Clang
Grab Clang installer for your platform. Run it and setup Clang.
Modify MSYS2 settings adding LLVM/bin to windows Path environment variable and your export in .bash_profile file
(export PATH=”/c/Program Files/LLVM/bin:/c/AddAnotherPathsIfNeeded/bin:$PATH”)
C++ Mingw-w64 toolchain
I decided to install Mingw-w64 toolchains as c++ toolkit. If you want to use them either follow simple steps.
To setup the Mingw-w642 environment, you need to:
- install MSYS2 and follow a instruction
- open MSYS2 MSYS terminal
- use pacman to install packages needed for c++ development
The following packages will be installed:
- GNU make
- gettext - a localization package
- base-devel - developer’s tools
- mingw-w64-x86_64-gcc - c++ 64-bit compiler toolchain
- mingw-w64-i686-gcc - c++ 32-bit compiler toolchain
- mingw-w64-x86_64-gdb mingw-w64-i686-gdb - 64-bit and 32-bit debuggers.
In your terminal type (copy/paste is OK too) line by line and press ENTER
pacman -S make gettext base-devel
pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-i686-gcc
pacman -S mingw-w64-x86_64-gdb mingw-w64-i686-gdb
To make cmake+ninja tools accessible in MSYS2 terminals modify your MSYS2 settings
Graphviz
Download Graphviz installer. Run it.
Remember to add Graphviz installation bin folder to Windows Path. To run graphviz tools in Mingw-w64 environment modify MSYS2 settings and add Graphviz/bin path to your export in .bash_profile file
(export PATH=”/c/Program Files/CMake/bin:/c/Program Files (x86)/Graphviz2.38/bin:$PATH”).
Additional software
-
For VsCode users!
To make your VsCode fully fledged C++ environment that supports cmake projects you need to install two additional extensions.
Checkpoint
To check your “devel” environment run MSYS2 terminal and run clang, clang++, g++, cmake, ninja and dot.
Sneak a peek at my MSYS2 .bash_profile file:
export PATH="/c/Program Files/LLVM/bin:/c/Program Files/CMake/bin:/c/Program Files (x86)/Graphviz2.38/bin:$PATH
Phew we are done.
-
You needn’t to install Visual Studio to use MSVC, you only have to install Microsoft build tools package (Microsoft C++ compiler + tools) ↩
-
another way to install MSYS2 and Mingw-w64 tools is using the package manager for Windows Chocolatey. ↩