MinGW, is the abbreviation for minimalist gnufor windows. We use MinGW to build a simple C language development environment.
First, install the MinGW
First go to the official website to download MinGW installation package: http://www.mingw.org/
In the left sidebar, click Download under Navigation.
Jump to SourceForge, download the latest version directly
Open the installation package to install MinGW.
Select Install.
Here you choose the installation path and some options, by default. Click Continue.
MinGW start downloading resources. Click Continue to continue after the download is complete.
Select the package you want to install, click on the left basic setup, select Mingw32-base and mingw32-gcc-g++ in the list. Select the mode, click on the left box, and select mark for installation in the pop-up menu.
menu, select installation, apply changes, pop-up window click Apply to start the installation.
Be patient for some time. Close closes the window when the installation is complete.
Close the window.
Second, configure environment variables
Right-click My Computer, properties, advanced system settings
In path, add the bin directory under your MinGW installation directory, mine is: E:\MinGW\bin.
Open cmd, enter gcc-v and g++-V, and you can see that the installation is complete.
Three, write a simple Hello world.
Write a simple HelloWorld program with Notepad. I saved it in the F-packing directory, named TEST.c. Editor you can use Vim, Emacs, Vscode, Sublime text, Atom, and so on, or use the Notepad that comes with Windows.
#include <stdio.h>int main () { printf ("Hello world! " ); return 0 ; }
Open cmd, enter the directory where the file is located, enter GCC test.c, you will find a a.exe in the F-disk, this is our compiled executable file. Run, Hello World, Success!
If you want to generate an executable file that is not called a.exe, but other names, you can use GCC test.c-o name, where the name is the file name you want.
So far, we have built a simple mingw-based small C language development environment.
Windows environment uses MINGW to establish a simple C language development environment