Site icon TestingDocs.com

Install GNU C/C++ Compiler on Windows

Overview

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.

Check Install

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.

Download

To install MinGW, navigate to the SourceForge website. The installer is hosted on the SourceForge hosting platform.

https://sourceforge.net/projects/mingw/

 

Click the Download button. The file would download to the browser download folder.

The filename would be mingw-<version>-setup.exe

or

mingw-get-setup.exe

Install

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, installing the software in the default install directory is always recommended.

Other install preferences.

Click on the Continue button.

The following install screen will appear.

 

Choose the setup type. Ensure that the Basic Setup is selected on the left.

Select the basic packages:

 

Right-click on the package and select Mark for Installation. However, you can select more packages for other language 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,

c:\mingw\bin>g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe
Target: mingw32
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.

Code::Blocks IDE

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:

https://www.testingdocs.com/download-and-install-codeblocks/

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.

Official Website

For more information on MinGW, visit the following website:

https://www.mingw-w64.org/

C++ Tutorials

C++ Tutorials on this website:

https://www.testingdocs.com/c-coding-tutorials/

For more information on the current ISO C++ standard

https://isocpp.org/std/the-standard

Exit mobile version