The installation tutorial of MinGW-w64 for gcc

1, What is MinGW-w64?

The full name of MinGW is: Minimalist GNU on Windows. In fact, GCC, the classic open source C language compiler, is ported to the windows platform and contains the Win32 API, so the source code can be compiled into executable programs that can run in windows. In addition, you can also use some development tools under Linux platform that Windows does not have. In a word, MinGW is the Windows version of GCC.

The above is the introduction of MinGW. The difference between MinGW-w64 and MinGW is that MinGW can only compile and generate 32-bit executable programs, while MinGW-w64 can compile and generate 64 bit or 32-bit executable programs.

Because of this, MinGW has been replaced by MinGW-w64, and MinGW has stopped updating. The built-in GCC has stagnated at version 4.8.1, while the built-in GCC of MinGW-w64 has been updated to version 6.2.0.


2, Why use MinGW-w64?

1. MinGW-w64 is open source software, which can be used free of charge.
2. MinGW-w64 is maintained by an active open source community, so it will not be out of date.
3. MinGW-w64 supports the latest C language standard.
4. MinGW-w64 uses the C language runtime library of Windows, so the compiled program does not need a third-party DLL, and can run directly under Windows.
5. Those famous open-source ides only encapsulate the MinGW-w64, making it have a friendly graphical interface and simplify the operation, but the internal core is still MinGW-w64.

MinGW-w64 is a stable, reliable and continuously updated C/C + + compiler, which can save you a lot of trouble, don't worry about not keeping up with the times, don't worry about the compiler itself has bug s, and you can write programs at ease.


3, What is MinGW-w64 suitable for?

For those familiar with MinGW-w64, it can compile any C program. But for the average person, the MinGW-w64 is too simple to have a graphical user interface. This makes people who are used to using the mouse feel very painful. Although there are some configurations that allow the MinGW-w64 to have a graphical user interface, that process is cumbersome.

In addition, when compiling complex programs, you need to be able to write makefiles. Otherwise, you can only compile one file for one file. You can imagine how hard it will be.

But for beginners of C language, MinGW-w64 is the right compiler. At least the black command prompt interface has a programming atmosphere and feels cool.

At the beginning of learning C language, all the code is usually written in one file. As long as you enter a few simple commands, you can use MinGW-w64 to compile into an executable file. Although compilers such as VS2015 can be compiled by clicking the mouse, they will automatically generate a large number of engineering files, leaving beginners confused. MinGW-w64 generates only one executable.

If we describe the compilers such as MinGW-w64 and VS2015, then MinGW-w64 is manual, while the compilers such as VS2015 are automatic. Therefore, the compilation process of MinGW-w64 is more intuitive and easy to understand, and it is also more suitable for C language learning.

All in all, for ordinary people, MinGW-w64 is suitable for learning C language, and VS2015 is better for real work. Of course, if you are working under Linux, Code::Blocks may be an option, but the biggest possibility is that you must be accustomed to using GCC to compile programs.


4, Download and install MinGW-w64

1. gcc installing home page , select Microsoft - > mingw64.

2. mingw-64 home page , select Download.

3. Mingw-w64 download page

Note: This is the download details page of MinGW-w64. First, I see a list titled pre build toolchains and packages, which contains the integration package of MinGW-w64 and specific tools. This tutorial only installs MinGW-w64, so you only need to download it.

Action: click the "SourceForge" hyperlink in the red box to enter the MinGW-w64 download page in SourceForge.

4. Double click Install Package to install

Parameter Description:

Version: select gcc version

Note: Version refers to the Version of gcc. If there is no special requirement, generally select the highest Version number.

Operation: in this version, the maximum version is 6.2.0. Select it.


Architecture: select computer system architecture

Note: Architecture refers to whether the computer system is 32-bit or 64 bit. Make the corresponding choice according to your computer system.

Operation: my computer system is 64 bit, so I chose x86_64, if you are a 32-bit system, choose i686.


Threads: select OS interface protocol

Note: there are only two operating systems in the world, posix compliant, and Windows. As the joke says, if you want to develop Windows programs, you need to choose win32, and if you want to develop programs under Linux, Unix, Mac OS and other operating systems, you need to choose posix.

Operation: I only develop programs running under Windows, so I chose win32.


Exception: select exception handling model (64 bit)

Note: exception handling is very important in development. Most of your time in the development process will be spent dealing with various exception situations. If you've chosen 64 bits before, here are two exception handling models for you to choose from. seh is a new invention, and sjlj is an old one. The performance of seh is good, but it does not support 32-bit. Sjlj has good stability and supports 32 bits.

Operation: I choose seh here.


Exception: select exception handling model (32-bit)

Note: after 32-bit is selected, two exception handling models, dwarf and sjlj, can be used. Likewise, dwarf has better performance than sjlj, because it does not support 64 bit.

Action: it is recommended to select dwarf.


Build revision: build revision

Explanation: I haven't figured out what to do for the time being. (please leave a message if you know)

Action: select the default option.

5. Select installation directory

6. Start downloading Mingw-w64 Ontology

7. Wait for the installation to complete

5, Testing

Execute the previous steps, open the command-line interface, enter gcc-v to view the version, and it's done!

PS C:\Users\February bird> gcc -v
Using built-in specs.
COLLECT_GCC=C:\Users\February bird\Downloads\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/Users/February bird/Downloads/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-8.1.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw810/x86_64-810-win32-seh-rt_v6-rev0/mingw64 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=win32 --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-win32-seh-rev0, Built by MinGW-W64 project' --with-bugurl= CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-win32-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-win32-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw810/x86_64-810-win32-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/x86_64-810-win32-seh-rt_v6-rev0/mingw64/opt/lib -L/c/mingw810/prerequisites/x86_64-zlib-static/lib -L/c/mingw810/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: win32
gcc version 8.1.0 (x86_64-win32-seh-rev0, Built by MinGW-W64 project)


Tags: Windows C zlib Linux

Posted on Thu, 25 Jun 2020 06:26:36 -0400 by jay_bo