Using Zeus with MinGW C/C++
Posted: Thu May 06, 2021 11:19 am
IMPORTANT: While the details on this page are correct, the versions of the compilers installed using this process are out dated.
To get more up to date compiler, a better option would be using MSYS2 to install these compilers as described here: https://www.zeusedit.com/phpBB3/viewtopic.php?t=8303
Another option is to download the compiler packages found here: https://winlibs.com/
For example, the GCC 13.2.0 UCRT Runtime package downloaded from that page reports with the following GCC version:
OBOLSETE INSTRUCTIONS LEFT HERE FOR HISTORICAL PURPOSES ONLY
The steps below describe how to get the MinGW C/C++ compiler up and running on Windows.
Step 1) Download the mingw-get-setup.exe file from the MinGW Setup Wizard page.
Step 2) Run that downloaded setup utility:
Step 3) This will bring up the installation wizard shown below:
Step 4) Walk through the steps of that setup wizard and when complete the MinGW Installer will have been installed and an icon to that program created on the desktop.
Running that installer will display the following screen: a. Select the packages you wish to install by right clicking on the items to be installed.
b. To install the selected packages, use the Installation, Apply Changes menu and select the Apply option in the resulting dialog.
NOTE: At a minimum select the mingw32-base (C compiler) and mingw32-gcc-g++ (C++ compiler) package options or alternatively select all the packages as shown in the image above.
Step 5) When running the installation using the wizard take note of the install folder used. Lets assume the install folder used as shown below:Step 3) Once the installation is complete use the Windows Control Panel to open up the System icon and use the Environment Variables button found in the Advanced system settings link to add this bin installation folder to the PATH environment variable.
IMPORTANT: Take care when editing this PATH environment variable. Only add to it. Never delete from it. More details about the PATH can be found here: http://www.zeusedit.com/phpBB3/viewtopic.php?f=5&t=6176
For the installation folder noted earlier, this bin folder will need to be added to the PATH:To check that PATH value is correct, check the bin folder exists and that it contains both the C++ compiler (g++.exe ) and the C compiler (gcc.exe) files.
In the steps that follow it is assumed the GNU C++ compiler is being used, but if the GNU C compiler is required, just replace the g++.exe command with the gcc.exe command.
Step 4) Test the PATH settings using the Windows Start Button and run the cmd executable to bring up a command prompt.
From inside that command prompt type in this C++ compiler command line:Running this command line should result in the following output:
To test the C compiler use this command line:
If you don't see output for either of those commands then the PATH has not been correctly configured or the installation has not worked.
Step 5)
Test the compiler by creating a simple c:\temp\test.cpp test file using the C++ code shown below:From inside the command prompt test the compiler by running the following commands:
Those commands change to the c:\temp\ folder and then run the C++ compiler to compile and link the c:\temp\test.cpp file to produce the c:\temp\test.exe executable.
Running those commands should produce the following output:Running the c:\temp\test.exe executable produced should result in this output:
To get more up to date compiler, a better option would be using MSYS2 to install these compilers as described here: https://www.zeusedit.com/phpBB3/viewtopic.php?t=8303
Another option is to download the compiler packages found here: https://winlibs.com/
For example, the GCC 13.2.0 UCRT Runtime package downloaded from that page reports with the following GCC version:
Code: Select all
c:\mingw32\bin>gcc.exe --version
gcc.exe (MinGW-W64 i686-ucrt-posix-dwarf, built by Brecht Sanders, r5) 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.
The steps below describe how to get the MinGW C/C++ compiler up and running on Windows.
Step 1) Download the mingw-get-setup.exe file from the MinGW Setup Wizard page.
Step 2) Run that downloaded setup utility:
Code: Select all
c:\temp\mingw-get-setup.exe
Running that installer will display the following screen: a. Select the packages you wish to install by right clicking on the items to be installed.
b. To install the selected packages, use the Installation, Apply Changes menu and select the Apply option in the resulting dialog.
NOTE: At a minimum select the mingw32-base (C compiler) and mingw32-gcc-g++ (C++ compiler) package options or alternatively select all the packages as shown in the image above.
Step 5) When running the installation using the wizard take note of the install folder used. Lets assume the install folder used as shown below:
Code: Select all
C:\mingw32\
IMPORTANT: Take care when editing this PATH environment variable. Only add to it. Never delete from it. More details about the PATH can be found here: http://www.zeusedit.com/phpBB3/viewtopic.php?f=5&t=6176
For the installation folder noted earlier, this bin folder will need to be added to the PATH:
Code: Select all
C:\mingw32\bin
In the steps that follow it is assumed the GNU C++ compiler is being used, but if the GNU C compiler is required, just replace the g++.exe command with the gcc.exe command.
Step 4) Test the PATH settings using the Windows Start Button and run the cmd executable to bring up a command prompt.
From inside that command prompt type in this C++ compiler command line:
Code: Select all
g++.exe --version
Code: Select all
g++ (MinGW.org GCC Build-20200227-1) 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.
Code: Select all
gcc.exe --version
Step 5)
Test the compiler by creating a simple c:\temp\test.cpp test file using the C++ code shown below:
Code: Select all
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world..." << endl;
return 0;
}
Code: Select all
cd c:\temp\
g++.exe test.cpp -o test.exe
dir test.exe
Running those commands should produce the following output:
Code: Select all
c:\>cd c:\temp\
c:\Temp>g++.exe test.cpp -o test.exe
c:\Temp>dir test.exe
Volume in drive D is DATA
Volume Serial Number is 06EC-1105
Directory of c:\Temp
21/05/2016 02:30 PM 2,707,662 test.exe
1 File(s) 2,707,662 bytes
0 Dir(s) 1,824,970,645,504 bytes free
Code: Select all
Hello world...