Install GNU C/C++ Compiler on Windows
In this tutorial, we will install GNU C/C++ Compiler on Windows operating system. GNU is a recursive acronym and stands for GNU is Not Unix. To install GCC on Windows we need to install MinGW. MinGW stands for “Minimalist GNU for Windows“. It is a minimalist development environment for native Microsoft Windows applications.
Let’s first check if GNU C/C++ Compiler is installed or configured on the system.
Open the Windows Command Prompt and run the following command.
\> g++ –version
If the output of the command is something like “g++ is not recognized as an internal or external command, operable program or batch file” then the GNU compiler is not installed or configured on the machine.
To install MinGW, navigate to the SourceForge website. The installer is hosted on the SourceForge hosting platform.
Click the Download button. The file would download to the browser download folder.
The filename would be mingw-<version>-setup.exe
Locate the installer in the download folder and double-click on the MinGW install manager setup.
Click on the Install button.
The following install screen window will appear. The default install location is: C:\MinGW
We can choose to install the software in any directory. However, it’s always recommended to install the software in the default install directory.
Other install preferences.
- Graphical User Interface support
- Install for All users or just for you
- Start Menu folder
- Desktop shortcut icon
Click on the Continue button.
The following install screen will appear.
Choose the setup type. Ensure on the left that Basic Setup is selected.
Select the basic packages::
Right-click on the package and select Mark for Installation. However, you can select more packages for other languages support.
Choose Installation >> Apply Changes menu option to install the selected packages.
Click on the Apply button to install the packages.
The packages would be installed on the machine. We can add the bin subdirectory to the system PATH environment variable.
The command should display the command output. For example,
Using built-in specs.
Configured with: ../src/gcc-6.3.0/configure –build=x86_64-pc-linux-gnu –host=mingw32 –with-gmp=/mingw –with-mpfr=/mingw –with-mpc=/mingw –with-isl=/mingw –prefix=/mingw –disable-win32-registry –target=mingw32 –with-arch=i586 –enable-languages=c,c++,objc,obj-c++,fortran,ada –with-pkgversion=’MinGW.org GCC-6.3.0-1′ –enable-static –enable-shared –enable-threads –with-dwarf2 –disable-sjlj-exceptions –enable-version-specific-runtime-libs –with-libiconv-prefix=/mingw –with-libintl-prefix=/mingw –enable-libstdcxx-debug –with-tune=generic –enable-libgomp –disable-libvtv –enable-nls
Thread model: win32
gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
That’s it, MinGW is now installed on the machine. Now, we can compile and run C++ programs on the Windows machine.
Another alternative to getting a GNU C/C++ compiler is to install an IDE that bundles the compiler. The easiest way to install a GNU compiler and an IDE for programming is to install Code::Blocks IDE.
Steps to install Code::Blocks IDE:
That’s it. MinGW mingw32-gcc-g++ Compiler package provides the implementation of the GNU C++ language compiler. We require this to compile C and C++ programs.
For more information on MinGW, visit the following website:
C++ Tutorials on this website:
For more information on the current ISO C++ standard