简体   繁体   中英

Installing the latest version of mingw-w64 on Windows

I am desperately trying to install the latest version of mingw-w64 to get acess to gcc 10 on windows 10.

I used the online installer for mingw-w64 in the past, but it is still stuck in 2018 on 8.1.0 and seems to be abandoned.

So i tried installing it manually.

On SourceForge or the GitHub Mirror you seem to only get a chunk of code without any clear instructions on what do do, how to build and install it. The only installation instructions that i managed to find required you to already have a working gcc installed (very helpful if that is what you want to get installed in the first place).

On their website and wiki there is a precompiled binary package mentioned. But the only one that i could find was horribly outdated as well.

Comparing this with the installation process of clang or the microsoft build tools, it actually blows my mind how something as basic as installation can be this confusing.

Maybe it's just me missing the obvious, but how do you actually install this thing?

GCC 10 is officially released. The personal build for Windows (MinGW-w64) that can be downloaded from https://winlibs.com requires no installation, just extract to a folder.

Building GCC on Windows from source code is very difficult and cannot be recommended to beginners. Moreover, GCC 10 has not yet been officially released and you may need to wait a few more weeks to get it.

If you want an up-to-date GCC in Windows (currently version 9.3), I recommend downloading and installing the MSYS2 package. Once you install it, launch it using the "MinGW64" icon and install the correct compiler in the terminal. For details, see this question: How to install MinGW-w64 and MSYS2?

Once you have done this, you can forget about MSYS2 and simply use the directory with the binaries in your PATH .

The maintainers of MSYS2 are very keen in supporting bleeding edge software, so once GCC 10 is released, you will be able to update to it (using the command pacman -Syu ) very soon.

I recommend obtaining MinGW through MSys2 https://www.msys2.org/

First install MSys2, then perform a full update by first updating the package database and updating pacman

pacman -SySu

After the update is done it will ask you to close the terminal without exiting to shell. Do so, then perform a full update by running

pacman -Su

after which you can install the mingw-w64 packages. Use

pacman -Ss mingw

to list all available packages. Install with

pacman -S ${PACKAGE_NAME}

Installing via MSYS2 will give you gcc 10.1.

You can treat MSYS2 as a package manager for keeping gcc up to date, and not use its shell if you like. Its packages include standalone 32-bit gcc, standalone 64-bit gcc, and MSYS2-target gcc. It is a very similar process to installing gcc via package manager on a Linux system.


how something as basic as installation can be this confusing

This is not uncommon with open source when there's no customer income stream to pay developers to build and maintain a smooth installer. Someone has to do the work of hosting and maintaining binary builds and often people will do it for a while out of the goodness of their heart, and then move on, as seems to have happened with the "official" mingw-builds installer.

So while the solutions you see on this thread today will work for now, in a few years' time the answers may be different

Go to Environment Variables. You should find it by searching for it in the search pane of control panel. As soon as you click Environment variables, you should see a new pop-up. Click the edit under System Variable. Navigate till you find 'PATH'. Click Edit.

Now very important steps. You will see an existing address under 'Variable Value'. Copy that (preferably to a Text doc). In that address, Delete the address containing mingw32 between two semicolons. And now add the address of the newly installed version's 'bin' folder (anywhere you want, importantly,between two semicolons).

Then paste the whole new address back again to the Variable Value field. Click OK for everything.

It should mostly work now. This is what I did. You can check if it updated by running 'g++ --version' in the CMD.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM