Table of Contents
In this lesson, you will learn how to prepare your local environment before you can start running C++ programs. C++ requires to have a compiler installed on the local machine to run correctly. You will also need a text editor to help you write the code with minimal hiccups. Our selection goes to CodeBlocks, which you will need to write, debug, and deploy C++ programs.
Set up Environment for C++
As mentioned above, we will install a compiler and a text editor before we can start coding in C++. For this purpose, CodeBlocks is an excellent code/text editor that can be used throughout this tutorial. It also supports many other languages, such as C, Perl, and Python. In this lesson, we will be using a windows environment for writing, debugging, and exciting the C++ code.
More like this:
Install CodeBlocks for Windows
To install CodeBlocks for windows, go to the download page http://www.codeblocks.org/downloads/26, then download the executable file from Sourceforge or FossHUB.
Run the installer once the download is completed, then follow on-screen instructions to install CodeBlock on your machine.
Install C++ Compiler for windows.
Again, a compiler is required to run C++ programs on your local machine. Fortunately, the version of CodeBlocks we installed above contains a compiler for C++, as it states on the download page.
Now, run the application for the first time; a compiler auto-detection screen will popup asking you to select a compiler for the newly installed CodeBlocks. Select the compiler that we just installed in the step above.
In case the CodeBlocks version you selected does not have a compiler included in the package, go to this article to learn how to install and setup the MinGW compiler for CodeBlocks.
Now we have our text editor and compiler set up for windows, take a moment to familiarize yourself with CodeBlocks. We will go through more details about creating a project, a file, running a program, etc. in the next few lessons.
Install CodeBlocks for Linux
Go to the download page and select the desired Linux version. See the note below from the application developer:
Similarly, follow the steps above to install the compiler for Linux OS.
Install CodeBlocks for Mac OS
From the same download page, scroll down to the download section for Mac OS. There is only one version of CodeBlocks for the Mac OS, at least for now. Please pay attention to the note from the application developer:
More Text Editors for C++
There are other Text Editors that you can use to write your C++ programs. Below are some of the popular ones that are available to you:
- List item
- Visual Studio Code
- Dev C++
- Eclipse
- NetBeans
- Atom
- CodeLite
- Sublime Text
Points to remember
- CodeBlocks is a text editor to write C++ Programs.
- A Compiler, such as MinGW, is required to run and debug C++ Programs.
- CodeBlocks can be installed on Linux and Mac.