How to Check the Version of the GCC C++ Compiler Installed on a Windows PC

In this article, we show how to check the version of the GCC C++ compiler installed on a Windows PC.
So you may be able to check the version of the C++ compiler you have installed on your computer by going through your computer file system and seeing where the compiler was installed and then looking at the version.
But another, probably better way of doing it, is to go to the command prompt on a Windows PC and typing in the following line shown below.
After you run this, the command prompt will return the version you have installed of the GCC C++ compiler.
This is shown below.

So you can see in this case that the version of the GCC C++ compiler that I have installed on my Windows PC is g++ 8.1.0.
So if you ever need to check the version of the GCC C++ compiler that you have installed on your PC, you can do it through the command prompt by typing in the single line, g++ —version, and this will return the result.
So this is how to check the version of the GCC C++ compiler installed in windows.
Как проверить версию gcc
GNU Compiler Collection (обычно используется сокращение GCC) — набор компиляторов для различных языков программирования, разработанный в рамках проекта GNU. GCC является свободным программным обеспечением, распространяется фондом свободного программного обеспечения (FSF) на условиях GNU GPL и GNU LGPL и является ключевым компонентом GNU toolchain. Он используется как стандартный компилятор для свободных UNIX-подобных операционных систем.
Изначально названный GNU C Compiler поддерживал только язык Си. Позднее GCC был расширен для компиляции исходных кодов на таких языках программирования, как C++, Objective-C, Java, Фортран, Ada, Go, GAS и D.
С версии 4.2.2 GCC перешёл на лицензию GPLv3.
Перед установкой
Проверить, установлен ли gcc можно в cmd командой
Если gcc установлени, Вы увидите версию
Если gcc не установлен, Вы увидите следующее сообщение
Microsoft Windows [Version 10.0.18363.720] (c) 2019 Microsoft Corporation. All rights reserved. C:\Users\Andrei>gcc —version 'gcc' is not recognized as an internal or external command, operable program or batch file.
Установка
Для работы в Windows нужен MinGW скачать его можно на сайте nuwen.net/mingw.html
Для этой статьи использовался mingw-17.1.exe
Далее действуйте по инструкции
Двойной клик на mingw-17.1.exe


После установки нужно добавить C:\MinGW\bin в системную переменную среды PATH.
Если Вы не знаете как это сделать, прочитайте мою статью «Системная переменная PATH»
Теперь команда gcc —version должна возвращать версию компилятора.
Microsoft Windows [Version 10.0.18363.720] (c) 2019 Microsoft Corporation. All rights reserved. C:\Users\Andrei>gcc —version gcc (GCC) 9.2.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.
Если этого не происходит — перезапустите консоль. Если не помогло — перезапустите Windows.
После установки
Итак, Вы установили MinGW написали простейшую программу 3.cpp, компилируете с помощью gcc
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Andrei\AppData\Local\Temp\ccuoNssB.o:3.cpp:(.text+0x28): undefined reference to `std::ios_base::Init::
Init()' c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Andrei\AppData\Local\Temp\ccuoNssB.o:3.cpp:(.text+0x58): undefined reference to `std::ios_base::Init::Init()' collect2.exe: error: ld returned 1 exit status
Мой совет — попробуйте g++
Если Вы планируете писать софт, который должен будет работать под UNIX-подобными ОС, например Linux или OpenBSD то устанавливать MinGW не стоит.
Попробуйте добавить в Ваш Windows подсистему для Linux и установить gcc там.
Установка gcc в подсистеме Linux для Windows
sudo apt install build-essentials
Установка Cygwin
Если по каким-то причинам Вам не подходят перечисленные выше варианты — установите cygwin cygwin.com
У меня пока что только негативный опыт работы с ним, но у Вас может получиться лучше.

Установка GCC в Linux
В зависимости от типа Linux выполните
sudo apt -y install gcc
Для Debian , Ubuntu и других deb
sudo yum -y install gcc
Для CentOS , Rocky , RHEL и других rpm
Подпишитесь на Telegram канал @aofeed чтобы следить за выходом новых статей и обновлением старых
gcc Getting started with gcc Determine gcc version
When referring to gcc’s documentation, you should know which version of gcc you are running. The GCC project has a manual for each version of gcc which includes features that are implemented in that version. Use the ‘-v’ option to determine the version of gcc you are running.
In this example we see that we are running gcc version 5.3.1. You would then know to refer to the GCC 5.3 manual. It is also helpful to include your gcc version when asking questions in case you have a version specific problem.
How to Check GCC Version on Ubuntu
Checking whether your GCC is running the latest release version is very important. This can be done using a variety of methods on Linux and other Unix-based operating systems.
GCC or GNU Compiler Collection is a widely used compiler developed by GNU Project. GCC is one of the most widely used open-source software development tools. It is a C, C++, and Objective-C compiler that supports most of the C++ standards. The software compiles C and C++ source code into object code and static binaries.
In this short howto, I will show how to check the GCC version of an Ubuntu system by using different commands.