Basics
C++ Installation
Installing C++
C++ installation uses compilers like GCC or MSVC for development.
Understanding C++ Compilers
To write and execute C++ programs, you need a compiler. A compiler is a tool that translates your C++ code into machine code that your computer can execute. The most commonly used C++ compilers are GCC (GNU Compiler Collection) and MSVC (Microsoft Visual C++).
Installing GCC on Linux
GCC is a popular choice on Linux systems. Use the following command to install GCC:
Once installed, verify the installation by checking the GCC version:
Installing GCC on Windows
For Windows users, GCC can be installed using MinGW or WSL (Windows Subsystem for Linux). Here, we will use MinGW:
- Download the MinGW installer from the official website.
- Run the installer and select 'gcc-g++' from the package list.
- Complete the installation process.
Installing MSVC on Windows
MSVC is part of the Visual Studio IDE, which is a comprehensive development environment for Windows:
- Download and install Visual Studio from the official Microsoft website.
- During installation, select the 'Desktop development with C++' workload.
- Once installed, open Visual Studio and start a new C++ project.
Verifying Your Installation
After installing your compiler, it's essential to verify that it's working correctly. You can do this by compiling a simple C++ program.
Save the above code in a file named hello.cpp
and compile it using the following command:
If the installation is successful, you should see Hello, World! printed on your terminal or command prompt.
Basics
- Previous
- Introduction
- Next
- Running Code