Steps for downloading and installing the MinGW-w64 (Minimalist GNU for Windows) toolset, which includes gcc, g++, and gdb. This toolset is essential for developing C and C++ programs on Windows 10 or Windows 11 computers. The installation will be carried out using the msys2 Software Distribution and Building Platform.
- MSYS2
- Once you have downloaded and installed
MSYS2launch it.
- Update the package db and base packages using pacman:
pacman -Syu
- Update the package db and base packages using pacman:
pacman -Su
- Open MinGW 64-bit from the Windows menu. You can search for packages with name gcc using:
pacman -Ss gcc - This will display all the packages for gcc. The one you are looking for (64-bit system) is:
pacman -S mingw-w64-x86_64-gcc
$ gcc --version
gcc.exe (Rev2, Built by MSYS2 project) 13.2.0
Copyright (C) 2023 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.$ g++ --version
g++.exe (Rev2, Built by MSYS2 project) 13.2.0
Copyright (C) 2023 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.
- You can search for packages with name gdb using:
pacman -Ss gdb - This will display all the packages for
gdb. The one you are looking for (64-bit system) is:
pacman -S mingw-w64-x86_64-gdb
gdb --version
GNU gdb (GDB) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.-
You won't be able to run any of your C and C++ programs from anywhere in your file system if you don't set the path environment variable.
-
Naviage to the location we installed MSYS2 and gcc.
-
It should be in the
C:\msys64\mingw64\bin -
From the Windows menu, search for Environment Variable and you should see "Edit the system environment variables" option.
-
Open that option and click the Environment Variables button and select the Path option in System variables;
-
Then click edit and select new and add the path
C:\msys64\mingw64\binand click OK.