简体   繁体   English

在Windows上安装最新版mingw-w64

[英]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.我正在拼命尝试安装最新版本的 mingw-w64 以访问 windows 10 上的 gcc 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.我以前用过mingw-w64的在线安装程序,但是2018年8.1.0上还是卡住了,好像被放弃了。

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.在 SourceForge 或 GitHub Mirror 上,您似乎只获得了一大段代码,而没有任何关于做什么、如何构建和安装它的明确说明。 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).我设法找到的唯一安装说明要求您已经安装了有效的 gcc(如果您首先要安装它,这将非常有用)。

On their website and wiki there is a precompiled binary package mentioned.在他们的网站和 wiki 上,提到了一个预编译的二进制 package。 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.将此与 clang 或 microsoft 构建工具的安装过程进行比较,它实际上让我大吃一惊,因为像安装这样基本的东西会如此令人困惑。

Maybe it's just me missing the obvious, but how do you actually install this thing?也许只是我错过了显而易见的事情,但是您如何实际安装这个东西?

GCC 10 is officially released. GCC 10 正式发布。 The personal build for Windows (MinGW-w64) that can be downloaded from https://winlibs.com requires no installation, just extract to a folder.可以从https://winlibs.com下载 Windows (MinGW-w64) 的个人版本不需要安装,只需解压到一个文件夹。

Building GCC on Windows from source code is very difficult and cannot be recommended to beginners.从源代码在 Windows 上构建 GCC 非常困难,不推荐给初学者。 Moreover, GCC 10 has not yet been officially released and you may need to wait a few more weeks to get it.此外,GCC 10 尚未正式发布,您可能需要再等几周才能获得。

If you want an up-to-date GCC in Windows (currently version 9.3), I recommend downloading and installing the MSYS2 package.如果您想要 Windows(当前版本 9.3)中的最新 GCC,我建议下载并安装 MSYS2 package。 Once you install it, launch it using the "MinGW64" icon and install the correct compiler in the terminal.安装后,使用“MinGW64”图标启动它并在终端中安装正确的编译器。 For details, see this question: How to install MinGW-w64 and MSYS2?有关详细信息,请参阅此问题: 如何安装 MinGW-w64 和 MSYS2?

Once you have done this, you can forget about MSYS2 and simply use the directory with the binaries in your PATH .完成此操作后,您可以忘记 MSYS2,只需使用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. MSYS2 的维护者非常热衷于支持前沿软件,因此一旦 GCC 10 发布,您将能够很快更新到它(使用命令pacman -Syu )。

I recommend obtaining MinGW through MSys2 https://www.msys2.org/我建议通过 MSys2 https://www.msys2.org/获取 MinGW

First install MSys2, then perform a full update by first updating the package database and updating pacman首先安装 MSys2,然后通过首先更新 package 数据库和更新 pacman 来执行完整更新

pacman -SySu

After the update is done it will ask you to close the terminal without exiting to shell.更新完成后,它会要求您关闭终端而不退出 shell。 Do so, then perform a full update by running这样做,然后通过运行执行完整更新

pacman -Su

after which you can install the mingw-w64 packages.之后您可以安装 mingw-w64 软件包。 Use利用

pacman -Ss mingw

to list all available packages.列出所有可用的软件包。 Install with安装

pacman -S ${PACKAGE_NAME}

Installing via MSYS2 will give you gcc 10.1. 通过 MSYS2 安装将为您提供 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.您可以将 MSYS2 视为 package 管理器,以使 gcc 保持最新状态,如果您愿意,请不要使用其 shell。 Its packages include standalone 32-bit gcc, standalone 64-bit gcc, and MSYS2-target gcc.其封装包括独立的 32 位 gcc、独立的 64 位 gcc 和 MSYS2 目标 gcc。 It is a very similar process to installing gcc via package manager on a Linux system.这与在 Linux 系统上通过 package 管理器安装 gcc 非常相似。


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.当没有客户收入 stream 来支付开发人员构建和维护流畅的安装程序时,这在开源中并不少见。 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.有人必须做托管和维护二进制构建的工作,人们通常会出于好心做一段时间,然后继续前进,就像“官方” mingw-builds 安装程序所发生的那样。

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. Go 到环境变量。 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.在该地址中,删除两个分号之间包含 mingw32 的地址。 And now add the address of the newly installed version's 'bin' folder (anywhere you want, importantly,between two semicolons).现在添加新安装版本的“bin”文件夹的地址(任何你想要的地方,重要的是,在两个分号之间)。

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.您可以通过在 CMD 中运行“g++ --version”来检查它是否已更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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