MinGW:安装gcc、g++

MinGW:安装gcc、g++


1.MinGW是什么?

wiki:https://en.wikipedia.org/wiki/MinGW

MinGW (“Minimalist GNU for Windows”), formerly mingw32, is a free and open source software development environment to create Microsoft Windows applications.

简单来说,MinGW是一系列工具集合,包括类似yum、rpm的库/包管理功能。

The development of the MinGW project has been forked with the creation in 2005–2008 of an alternative project called Mingw-w64.

MinGW有一个fork版本,即Mingw-w64。(同时支持32bit和64bit)

MinGW includes a port of the GNU Compiler Collection (GCC), GNU Binutils for Windows (assembler, linker, archive manager), a set of freely distributable Windows specific header files and static import libraries which enable the use of the Windows API, a Windows native build of the GNU Project’s GNU Debugger, and miscellaneous utilities.

MinGW包括的内容,有gcc编译器、链接器、头文件等。

MinGW can be run either on the native Microsoft Windows platform, cross-hosted on Linux (or other Unix), or “cross-native” on Cygwin. Although programs produced under MinGW are 32-bit executables, they can be used both in 32 and 64-bit versions of Windows.

注意:基于MinGW生成的可执行文件都是32bit的。


2.MinGW怎么装?

2.1.安装目录

D:\app\MinGW

2.2.下载文件

https://sourceforge.net/projects/mingw/

mingw-get-setup.exe

在这里插入图片描述

2.3.安装 MinGW Installation Manager

在这里插入图片描述

注意,选择安装目录为:D:\app\MinGW

在这里插入图片描述
安装中…

在这里插入图片描述
在这里插入图片描述

点击:Continue

在这里插入图片描述

安装成功后,将会自动打开 MinGW Installation Manager:

在这里插入图片描述

此时,MinGW/bin中仅有mingw-get.exe。

EB@DESKTOP-K45IA6V MINGW64 /d/app
$ ll MinGW/
total 0
drwxr-xr-x 1 EB 197609 0 Jun 22 14:58 bin/
drwxr-xr-x 1 EB 197609 0 Jun 22 14:58 libexec/
drwxr-xr-x 1 EB 197609 0 Jun 22 14:58 share/
drwxr-xr-x 1 EB 197609 0 Jun 22 14:58 var/

EB@DESKTOP-K45IA6V MINGW64 /d/app
$ ll MinGW/bin
total 52
-rwxr-xr-x 1 EB 197609 52224 Oct  5  2013 mingw-get.exe*

在这里插入图片描述

2.4.安装 gcc、g++等库/包

选中所有的package:

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

点击左上角Installation:Apply Changes,进行安装:

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

安装完成,关闭对话窗口:

在这里插入图片描述
在这里插入图片描述
此时,MinGW\bin中包含我们常见的:

c++.exe、cpp.exe、g++.exe、gcc.exe、gdb.exe、ld.exe、nm.exe、objdump.exe等等。

$ ll c++.exe cpp.exe g++.exe gcc.exe gdb.exe ld.exe nm.exe objdump.exe
-rwxr-xr-x 1 EB 197609   997902 May 30  2017 c++.exe*
-rwxr-xr-x 1 EB 197609   996366 Jul 25  2017 cpp.exe*
-rwxr-xr-x 1 EB 197609   997902 May 30  2017 g++.exe*
-rwxr-xr-x 1 EB 197609   995342 Jul 25  2017 gcc.exe*
-rwxr-xr-x 1 EB 197609 30595068 Sep 15  2013 gdb.exe*
-rwxr-xr-x 1 EB 197609  1291278 May 22  2017 ld.exe*
-rwxr-xr-x 1 EB 197609   978958 May 22  2017 nm.exe*
-rwxr-xr-x 1 EB 197609  1756174 May 22  2017 objdump.exe*

在这里插入图片描述

2.5.配置环境变量PATH

将D:\app\MinGW\bin添加到环境变量PATH中:

控制面板\系统和安全\系统->高级系统设置->环境变量->用户变量->编辑变量PATH:

在这里插入图片描述

新增路径D:\app\MinGW\bin,然后确认保存即可。

在这里插入图片描述


3.MinGW测试使用

在这里插入图片描述

Microsoft Windows [版本 10.0.17763.107]
(c) 2018 Microsoft Corporation。保留所有权利。

C:\Users\EB>where gcc g++
D:\app\MinGW\bin\gcc.exe
D:\app\MinGW\bin\g++.exe

C:\Users\EB>gcc --version
gcc (MinGW.org GCC-6.3.0-1) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


C:\Users\EB>g++ --version
g++ (MinGW.org GCC-6.3.0-1) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

4.MinGW安装常见问题?

4.1.报错1

mingw-get: *** ERROR *** http://prdownloads.sourceforge.net/mingw/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.tar.xz?download:cannot open URL

在这里插入图片描述

解决方法:科学上网。

4.2.报错2

在这里插入图片描述

解决方法:科学上网。

  • 5
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
要在Windows安装GCCg++,您可以按照以下步骤进行操作: 1. 首先,您需要下载MinGW(Minimalist GNU for Windows安装程序。您可以在MinGW的官方网站(https://osdn.net/projects/mingw/)上找到最新版本的安装程序。 2. 打开MinGW安装程序并选择您想要安装的组件。确保选择了“C++编译器”和“MSYS基础系统”,然后点击“安装”按钮。 3. 安装过程可能需要一些时间,请耐心等待直到安装完成。 4. 安装完成后,您需要将MinGW安装路径添加到系统的环境变量中。打开Windows的控制面板,选择“系统和安全”,然后点击“系统”。 5. 在系统窗口中,点击左侧的“高级系统设置”链接。 6. 在弹出的窗口中,点击“环境变量”按钮。 7. 在环境变量窗口中,找到系统变量列表中的“Path”变量,并点击“编辑”按钮。 8. 在编辑环境变量窗口中,点击“新建”按钮,并将MinGW安装路径添加到新建的条目中(例如:C:\MinGW\bin)。 9. 点击“确定”按钮关闭所有打开的窗口。 现在,您应该已经成功安装GCCg++编译器。要验证安装是否成功,打开命令提示符(按下Win + R键,输入“cmd”并按下Enter键),然后在命令提示符中输入以下命令: ``` gcc --version g++ --version ``` 如果您看到GCCg++的版本信息,则表示安装成功。 希望这可以帮助您在Windows安装GCCg++!如果您有任何其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值