To install MinGW, follow these steps:
-
Download MinGW:
- Go to the MinGW website: MinGW — Minimalist GNU for Windows.
- Look for the "Downloads" section and download the installer appropriate for your system (32-bit or 64-bit).
-
Run the Installer:
- Execute the installer you downloaded.
- Follow the installation instructions.
- During installation, you’ll be prompted to select components. Make sure to include the C++ compiler (usually named mingw32-gcc-g++).
-
Add MinGW to System Path (Optional but recommended):
- After installation, add the MinGW bin directory to your system's PATH environment variable. This step allows you to run the compiler from any command prompt.
- For example, if MinGW is installed in C:\MinGW, add C:\MinGW\bin to your PATH.
After completing these steps, you should be able to compile C++ programs using MinGW. Here's an example of how to compile a C++ program:
-
Create a C++ file: Save the file with a .cpp extension, such as hello.cpp. You can use any text editor to create this file.
-
Compile the C++ file: Open a command prompt and navigate to the directory where your hello.cpp file is saved. Then, run the following command to compile the program:
g++ hello.cpp -o hello.exe
-
Run the compiled program: After successful compilation, you can run the compiled executable by typing its name in the command prompt:
hello.exe
That's it! You've installed MinGW and compiled a simple C++ program.
Microsoft Windows [Version 10.0.19045.4046] (c) Microsoft Corporation. All rights reserved. C:\Users\User>F:\
'F:\' is not recognized as an internal or external command, operable program or batch file.
C:\Users\User>F:
F:\>g++
g++: fatal error: no input files
compilation terminated.
F:\>g++ hello.cpp -o hello.exe
F:\>cd EclipseProject
F:\EclipseProject>dir
Volume in drive F is DIGILINE Volume Serial Number is F083-5E6D
Directory of F:\EclipseProject 03/07/2024 05:44 PM <DIR> . 03/07/2024 05:44 PM <DIR> .. 03/01/2024 04:00 PM <DIR> .metadata 03/07/2024 04:19 PM <DIR> CoolMind 03/06/2024 04:43 PM <DIR> curl-8.6.0_3-win32-mingw 03/04/2024 12:02 PM 7,654,385 curl-8.6.0_3-win32-mingw.zip 03/06/2024 04:23 PM 7,650,039 curl-8.6.0_3-win64-mingw.zip 03/08/2024 03:07 PM <DIR> MyKeyLogger 2 File(s) 15,304,424 bytes 6 Dir(s) 65,506,320,384 bytes free
F:\EclipseProject>cd MyKeyLogger F:\EclipseProject\MyKeyLogger>dir
Volume in drive F is DIGILINE Volume Serial Number is F083-5E6D
Directory of F:\EclipseProject\MyKeyLogger 03/08/2024 03:07 PM <DIR> . 03/08/2024 03:07 PM <DIR> .. 03/08/2024 02:12 PM 12,190 .cproject 03/07/2024 04:01 PM 839 .project 03/07/2024 04:03 PM <DIR> .settings 03/08/2024 03:09 PM <DIR> Debug 03/08/2024 03:22 PM 2,791 MyLogger.cpp 3 File(s) 15,820 bytes 4 Dir(s) 65,506,320,384 bytes free
F:\EclipseProject\MyKeyLogger>g++ MyLogger.cpp -o MyLogger.exe
MyLogger.cpp:44:7: warning: multi-character character constant [-Wmultichar]
case 'A_':
^~~~
F:\EclipseProject\MyKeyLogger>
Â
Comments