win10安装MinGW

  MinGW,Minimalist GNU for Windows,windows最简化的GNU,就是一个C的编译工具集,转为windows操作系统下的C/C++开发者服务。我们从官网下载安装程序,打开官网后右边菜单栏点击Downloads:

 

 

  跳往下载列表页面后,往下拉,点击安装程序下载:

 

 

   最后双击该exe执行安装,弹出安装界面:

 

  接下来默认给你设置好了安装目录和勾选了默认设置,点击继续:

 

 

 

 

   最后进入安装包阶段,左边窗口有两个按钮:基础必备的和全部的,对应右边的详细列表:

 

 

  点击复选框,下面窗口会说明这个包用来干嘛, 在弹出的框中点击Mark for Installation安装标记后,点击左上角的Installation -> Apply Changes:

 

 

 

 

 

  虽然只是这几个基础包,下载也不容易,毕竟是外网,老是链接超时:

 

   

   而且它会反复尝试,退不出来,只能用任务管理器把它kill掉。既然此路不通,只能另走他路。我们打开命令行,进入C盘的MinGW目录bin路径,敲命令安装:

C:\MinGW\bin>mingw-get install gcc
http://osdn.net/dl/mingw/gcc-9.2.0-2-mingw32-lic.tar.xz
21.33 kB / 21.33 kB     |================================================| 100%
http://osdn.net/dl/mingw/libiconv-1.14-4-mingw32-dll-2.tar.xz
642.41 kB / 642.41 kB   |================================================| 100%
http://osdn.net/dl/mingw/libatomic-9.2.0-2-mingw32-dll-1.tar.xz
7.47 kB / 7.47 kB       |================================================| 100%
http://osdn.net/dl/mingw/libgcc-9.2.0-2-mingw32-dll-1.tar.xz
167.01 kB / 167.01 kB   |================================================| 100%
http://osdn.net/dl/mingw/libgmp-6.1.2-3-mingw32-dll-10.tar.xz
204.25 kB / 204.25 kB   |================================================| 100%

  如果还是出现链接下载失败:

http://osdn.net/dl/mingw/gcc-9.2.0-2-mingw32-lang.tar.xz
1.57 MB / 1.57 MB       |================================================| 100%
mingw-get: *** ERROR *** http://osdn.net/dl/mingw/gcc-core-9.2.0-2-mingw32-bin.tar.xz:cannot open URL; status = 12029
mingw-get: *** ERROR *** Get package: http://osdn.net/dl/mingw/gcc-core-9.2.0-2-mingw32-bin.tar.xz: download failed
install: gcc-9.2.0-2-mingw32-lic.tar.xz

  我们重新执行一次即可,它会把失败的jar包重新下载:  

C:\MinGW\bin>mingw-get install gcc
http://osdn.net/dl/mingw/gcc-core-9.2.0-2-mingw32-bin.tar.xz
17.05 MB / 17.05 MB     |================================================| 100%
install: gcc-9.2.0-2-mingw32-lic.tar.xz
mingw-get: *** ERROR *** package gcc-9.2.0-2-mingw32-lic.tar.xz is already installed
install: gcc-core-9.2.0-2-mingw32-bin.tar.xz
 installing gcc-core-9.2.0-2-mingw32-bin.tar.xz
install: gcc-core-4.8.2-2-mingw32-dev.tar.lzma
mingw-get: *** ERROR *** package gcc-core-4.8.2-2-mingw32-dev.tar.lzma is already installed
install: gcc-core-4.8.1-5-mingw32-doc.tar.lzma
mingw-get: *** ERROR *** package gcc-core-4.8.1-5-mingw32-doc.tar.lzma is already installed
install: gcc-9.2.0-2-mingw32-man.tar.xz
mingw-get: *** ERROR *** package gcc-9.2.0-2-mingw32-man.tar.xz is already installed
install: gcc-9.2.0-2-mingw32-info.tar.xz
mingw-get: *** ERROR *** package gcc-9.2.0-2-mingw32-info.tar.xz is already installed
install: gcc-9.2.0-2-mingw32-lang.tar.xz
mingw-get: *** ERROR *** package gcc-9.2.0-2-mingw32-lang.tar.xz is already installed

 

  一直下载不下来,我们也可以自己打开上面提示的下载地址页面,自己去下载:

 

   然后需要手动把下载的包放到指定目录下:

 

 

 

  同上,继续执行g++、gdb和mingw32-make的下载:

C:\MinGW\bin>mingw-get install g++
http://osdn.net/dl/mingw/gcc-c++-9.2.0-2-mingw32-bin.tar.xz
10.39 MB / 10.39 MB     |================================================| 100%
http://osdn.net/dl/mingw/gcc-c++-9.2.0-2-mingw32-man.tar.xz
255.52 kB / 255.52 kB   |================================================| 100%
C:\MinGW\bin>mingw-get install gdb
http://osdn.net/dl/mingw/libz-1.2.11-1-mingw32-dll-1.tar.xz
62.95 kB / 62.95 kB     |================================================| 100%

 

  gdb的话这个链接http://prdownloads.sourceforge.net死活连不上,我认为这个网址变更了,去掉了前面的prdownloads.变成如下链接:https://sourceforge.net/projects/mingw/files/MinGW/Extension

 

  我们把这几个下载下来:

 

 

 

   把上面6个压缩包放到C:\MinGW\var\cache\mingw-get\packages目录中,重新安装一次。

  mingw32-make也是如法炮制:

  1、命令行执行安装失败(还是这个prdownloads.sourceforge.net):

C:\>mingw-get install mingw32-make
mingw-get: *** ERROR *** http://prdownloads.sourceforge.net/mingw/make-3.82.90-2-mingw32-cvs-20120902-bin.tar.lzma?download:cannot open URL; status = 12031
mingw-get: *** ERROR *** Get package: http://prdownloads.sourceforge.net/mingw/make-3.82.90-2-mingw32-cvs-20120902-bin.tar.lzma?download: download failed
mingw-get: *** ERROR *** http://prdownloads.sourceforge.net/mingw/make-3.82.90-2-mingw32-cvs-20120902-doc.tar.lzma?download:cannot open URL; status = 12031
mingw-get: *** ERROR *** Get package: http://prdownloads.sourceforge.net/mingw/make-3.82.90-2-mingw32-cvs-20120902-doc.tar.lzma?download: download failed
mingw-get: *** ERROR *** http://prdownloads.sourceforge.net/mingw/make-3.82.90-2-mingw32-cvs-20120902-lic.tar.lzma?download:cannot open URL; status = 12031
mingw-get: *** ERROR *** Get package: http://prdownloads.sourceforge.net/mingw/make-3.82.90-2-mingw32-cvs-20120902-lic.tar.lzma?download: download failed
mingw-get: *** ERROR *** http://prdownloads.sourceforge.net/mingw/make-3.82.90-2-mingw32-cvs-20120902-lang.tar.lzma?download:cannot open URL; status = 12031
mingw-get: *** ERROR *** Get package: http://prdownloads.sourceforge.net/mingw/make-3.82.90-2-mingw32-cvs-20120902-lang.tar.lzma?download: download failed

 

  2、到sourceforge.net网站上找对应的包(一般都是找最上面那个最新的):

 

 

   3、下完后放到mingw的包目录中:

 

 

 

  4、重现用命令行执行以下安装:

C:\>mingw-get install mingw32-make
install: make-3.82.90-2-mingw32-cvs-20120902-bin.tar.lzma
 installing make-3.82.90-2-mingw32-cvs-20120902-bin.tar.lzma
install: make-3.82.90-2-mingw32-cvs-20120902-doc.tar.lzma
 installing make-3.82.90-2-mingw32-cvs-20120902-doc.tar.lzma
install: make-3.82.90-2-mingw32-cvs-20120902-lic.tar.lzma
 installing make-3.82.90-2-mingw32-cvs-20120902-lic.tar.lzma
install: make-3.82.90-2-mingw32-cvs-20120902-lang.tar.lzma
 installing make-3.82.90-2-mingw32-cvs-20120902-lang.tar.lzma

  

  最后把MinGW配置到系统环境变量中,方便使用以上工具:右键点击“此电脑” -> 选择“属性” -> 选“高级系统设置” -> 点“环境变量” -> 选“Path”后点编辑 -> 在弹出框点新建,把C:\MinGW\bin的路径加进去:

 

  确认下我们的安装:

C:\Users\wuxun>gcc -v
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/lto-wrapper.exe
gcc 版本 9.2.0 (MinGW.org GCC Build-2)

C:\Users\wuxun>g++ -v
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/lto-wrapper.exe
gcc 版本 9.2.0 (MinGW.org GCC Build-2)

C:\>gdb -v
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.

C:\>mingw32-make -v
GNU Make 3.82.90
Built for i686-pc-mingw32
Copyright (C) 1988-2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

 

posted on 2020-07-23 07:32  不想下火车的人  阅读(9473)  评论(5编辑  收藏  举报

导航