There are a number of different ways to set up a C++ development environment.
C++ Compilers
Linux
Most Un*x/Linux distributions come with a number of development and build tools, which you can selectively install. The core/essential build tools packages generally include C/C++ compilers such as gcc/g++ or clang.
For example, on Ubuntu,
sudo apt install build-essential
This will install g++, among other tools.
$ g++ --version
g++ (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
If you prefer to use clang, you can additionally install it.
(You will always need the build-essential package
if you plan to do any low-level C/C++ development on Ubuntu.
For instance, the package includes the make
tool,
which is used for C/C++ program development.)
sudo apt clang
$ clang --version
clang version 10.0.0-4ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Refer to other resources for installing C++ development tools on other Un*x/Linux like platforms, including Mac.
Windows
On Windows, it is recommended to use a Linux distribution on top of WSL. The C++ support on Windows has always been less than optimal unless you are only building Windows specific applications.
Clearly, Visual Studio is one of the best developer tools, and it has an excellent support for C++ development. If you end up using Visual Studio on Windows, do not use the "managed C++" version.
cmake
Although it is not required,
cmake
is widely used for cross-platform development.
We highly recommend you start using cmake
if you are serious about learning real C++ development.
On Ubuntu, for example, you can install it as follows:
sudo apt install cmake
We will further discuss cmake
in a later post,
but it can be used to "automatically" generate Makefiles for different platforms
based on the project configuration.
Gradle
C++ is one of the oldest and still the most widely used language, and yet it does not have the "infra" or "ecosystem" for development support. For instance, C++ does not have a central "package repository" like (virtually) every modern programming language (although there have been many (still ongoing) efforts in the C++ community).
Another thing is, although trivial, C++ does not have "official" project management tools and/or program scaffolding tools. It is not absolutely necessary, but developers who are used to the modern language dev toolchains sometimes miss such a tool.
Gradle is one of the tools that provide provide basic C++ app scaffolding as well as building and testing (like Makefile).
You can install the current version of Gradle from their official website:
What's Next
Now that we have a development environment set up, let's try creating a simple program.
- Next Step: Creating the first program in C++
C C# Clojure Crystal D Dart Erlang F# Go Haskell Java Javascript Julia Kotlin Lua Python Rust Scala Swift Typescript