简体   繁体   English

如何在 Windows 上的 MinGW 中更新 GCC?

[英]How to update GCC in MinGW on Windows?

I'm used to manually install GCC from source before on Ubuntu and it was a painful process.我以前习惯在 Ubuntu 上从源代码手动安装 GCC,这是一个痛苦的过程。 So I really don't want to do repeat this process.所以我真的不想重复这个过程。 Currently, I have MinGW and GCC (4.6.2) installed on my machine.目前,我的机器上安装了 MinGW 和 GCC (4.6.2)。 So is there an easy way to update GCC without building it entirely from source?那么有没有一种简单的方法来更新 GCC 而无需完全从源代码构建它? Has anyone done it before can share me some tips?有没有人以前做过可以分享一些技巧?

Update using terminal:使用终端更新:

  1. Run the command prompt/terminal ( cmd or sh ).运行命令提示符/终端( cmdsh )。

  2. Update the package list:更新包列表:

     mingw-get update
  3. After updating the package list, run:更新包列表后,运行:

     mingw-get upgrade

When the command finishes running, all of your packages will be upgraded.当命令完成运行时,您的所有软件包都将升级。


Update using the GUI version:使用 GUI 版本更新:

If you aren't used to the terminal, there is also a GUI version of MinGW called "MinGW Installation Manager", which is normally located at:如果你不习惯终端,还有一个名为“MinGW 安装管理器”的 MinGW 的 GUI 版本,它通常位于:

C:\MinGW\libexec\mingw-get\guimain.exe
  1. When the GUI is open, tap Installation -> Update Catalogue .当 GUI 打开时,点击Installation -> Update Catalogue This will update the package list.这将更新包列表。

  2. After that, tap Installation -> Mark All Upgrades .之后,点击Installation -> Mark All Upgrades This will select all of the packages which can be upgraded.这将选择所有可以升级的包。

  3. Finally, tap Installation -> Apply Changes to apply the upgrades.最后,点击Installation -> Apply Changes以应用升级。

UPDATE: As of Nov-5-2012, MinGW includes 4.7.2 of the GCC compiler, which is the most current version.更新:截至 2012 年 11 月 5 日, MinGW包含 GCC 编译器的 4.7.2,这是最新版本。 I personally will use the MinGW package, since it includes MSYS and other tools, and since it is the defacto standard, I hope that it is better supported.我个人会使用MinGW的包,因为它包含了MSYS等工具,而且因为它是事实上的标准,希望得到更好的支持。 The only drawback is the included GDB does not include Python scripting, but I think that can be updated separately.唯一的缺点是包含的 GDB 不包含 Python 脚本,但我认为可以单独更新。


I don't know if you can update the GCC in MinGW, but there are alternative projects to MinGW with newer versions of GCC.我不知道你是否可以更新 MinGW 中的 GCC,但是有新版本的 GCC 的 MinGW 替代项目。

The MinGW-builds project provides a package similar to MinGW but with an updated GCC (4.7.2). MinGW-builds项目提供了一个类似于 MinGW 的包,但具有更新的 GCC (4.7.2)。 I extracted the files to c:\\MinGW (so I could use the same path) after moving my existing MinGW to another folder.将现有的 MinGW 移动到另一个文件夹后,我将文件解压缩到 c:\\MinGW(因此我可以使用相同的路径)。 Only MinGW has MSYS , so if you need that (I did) copy the msys folder from the original MinGW.只有 MinGW 有MSYS ,所以如果你需要(我做了)从原始 MinGW 复制 msys 文件夹。

After installing MinGW-builds, the result of g++ --version:安装MinGW-builds后,g++ --version的结果:

g++ (Built by MinGW-builds project) 4.7.2

The latest GCC that comes with standard MinGW is currently 4.7.0.标准 MinGW 附带的最新 GCC 目前是 4.7.0。 I compiled a few simple projects in Code::Blocks, and the latest wxWidgets source, and everything seems to work.我在 Code::Blocks 和最新的 wxWidgets 源代码中编译了几个简单的项目,似乎一切正常。

It's worth noting that MinGW-builds includes a Python script enabled version of GDB, in case you want STL pretty printer support, or other GDB Python features.值得注意的是,MinGW-builds 包含一个启用 Python 脚本的 GDB 版本,以防您需要 STL 漂亮的打印机支持或其他GDB Python功能。

Another good choice is TDM-GCC , which is a project that hosts an impressive installer that includes an updated GCC compiler (4.7.1) and support tools.另一个不错的选择是TDM-GCC ,这是一个包含令人印象深刻的安装程序的项目,其中包括更新的 GCC 编译器 (4.7.1) 和支持工具。 It is a standalone package.它是一个独立的包。 As far as I can tell, Python scripting is not supported in the GDB that comes with this package.据我所知,此包附带的 GDB 不支持 Python 脚本。

Finally there is the MinGW-w64 project, which is a fork of MinGW.最后是MinGW-w64项目,它是 MinGW 的一个分支。 Rubenvb, who posted an answer to this question, has good standalone packages (in the personal builds folder) based on this project which include an updated GCC (4.7.2). Rubenvb 发布了这个问题的答案,基于这个项目有很好的独立包(在个人构建文件夹中),其中包括更新的 GCC (4.7.2)。 The included GDB seems to be Python script enabled.包含的 GDB 似乎启用了 Python 脚本。

if you use MSYS2 just open mingw64-console and type in:如果您使用MSYS2,只需打开 mingw64-console 并输入:

# Update the package database and core system packages with:
pacman -Syu  

# If needed, close MSYS2, run it again from Start menu. Update the rest with:
pacman -Su

I have built a more up to date GCC 4.7 (it's built within code freeze, so it should be equivalent with the release).我已经构建了一个更新的 GCC 4.7(它是在代码冻结中构建的,所以它应该与发行版等效)。 Also, this build contains <thread> support.此外,此版本包含<thread>支持。

The -gcc _linux package is what you want if you want to use it on Linux.如果您想在 Linux 上使用-gcc _linux 包,那么它就是您想要的。 Just extract somewhere and add the mingw??/bin directory to PATH.只需提取某处并将mingw??/bin目录添加到 PATH。

PS: There's a native Windows compiler and a Windows Clang build. PS:有一个本地 Windows 编译器和一个 Windows Clang 构建。 I suggest using Clang only with one of my GCC 4.6 builds, as it has trouble with GCC 4.7's libstd++.我建议只在我的 GCC 4.6 版本之一中使用 Clang,因为它在 GCC 4.7 的 libstd++ 上有问题。 Extract the Clang package in the same directory as the GCC package and it will work out of the box.将 Clang 包解压到与 GCC 包相同的目录中,它将开箱即用。

To get latest MinGW64 in Windows:https://sourceforge.net/projects/mingw-w64/?source=typ_redirect在 Windows 中获取最新的 MinGW64:https ://sourceforge.net/projects/mingw-w64/?source= typ_redirect

For all platforms: https://mingw-w64.org/doku.php/download适用于所有平台: https : //mingw-w64.org/doku.php/download

The MinGW-w64 build from http://winlibs.com/ has the latest GCC version and requires no installation, just unzip the download.来自http://winlibs.com/的 MinGW-w64 版本具有最新的 GCC 版本,无需安装,只需解压下载即可。 To upgrade you can just replace the mingw32 or mingw64 folder with the new version.要升级,您只需将 mingw32 或 mingw64 文件夹替换为新版本即可。

You just need to update your g++ compiler if its not.如果不是,您只需要更新您的 g++ 编译器。

First problem can be solved through this:第一个问题可以通过这个解决:

Update using the GUI version:使用 GUI 版本更新:

If you aren't used to the terminal, there is also a GUI version of MinGW called "MinGW Installation Manager", which is normally located at:如果你不习惯终端,还有一个名为“MinGW 安装管理器”的 MinGW 的 GUI 版本,它通常位于:

C:\\MinGW\\libexec\\mingw-get\\guimain.exe When the GUI is open, tap C:\\MinGW\\libexec\\mingw-get\\guimain.exe 打开 GUI 后,点击

Installation -> Update Catalogue

. . This will update the package list.这将更新包列表。

After that, tap之后,点击

Installation -> Mark All Upgrades

. . This will select all of the packages which can be upgraded.这将选择所有可以升级的包。 Finally, tap最后,点击

Installation -> Apply Changes 

to apply the upgrades.应用升级。

2nd Problem could be that if you didn't updated the path of mingw in environment variables.第二个问题可能是,如果您没有在环境变量中更新 mingw 的路径。

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

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