msys2 安装笔记

以前一直在用 msys,最近发现还有个 msys2,并且msys2 配套的编译器是MinGW-w64。 就试着用了用,感觉还不错,这里把安装过程记录一下。

简单的说,MSYS2 MSYS的一个升级版提供了bash shell, Autotools, 版本控制软件和MinGW-w64 工具链。与MSYS最大的区别是移植了 Arch Linux的软件包管理系统 Pacman。有了 Pacman 升级系统,安装新软件包,还有解决软件包间的依赖问题就变得简单多了。

可以在这里查看MSYS2包括了哪些软件包:

https://github.com/Alexpux/MSYS2-packages

安装

msys2 的主页地址:

http://sourceforge.net/projects/msys2/

 

首先下载安装文件,我的系统是32位的,所以下载32位的安装包:

msys2-i686-20140910.exe

 

msys2 要求安装目录只能有 ascii 字符并且不能有空格。我选择安装在:

C:/msys32

这样安装完后只有最基本的系统,没有gcc开发环境。运行如下命令可以打开一个bash shell

msys2_shell.bat

剩下的工作都在这个bash shell下进行。

msys2 移植了Arch Linux 上的软件包管理系统 Pacman,有了包管理系统,升级、安装新的软件就很简单了。 不过我一直在用redhat 系的linux没有接触过 Pacman,学习新命令还是花了些时间。这里把一些常见的Pacman命令记录一下。

更新本地软件包

更新本地软件包数据库:

pacman -S --refresh

可以缩写为:pacman -Sy

然后升级软件包:

pacman -S --refresh --sysupgrade 

可以缩写为:pacman -Syu

 

这里需要特别注意,不能写为:

pacman -Su

给出的理由如下,我水平太低,没完全理解是啥意思:

because all MSYS2 programs share the same address space for DLLs due to how MSYS2 (well, Cygwin) implements 'fork', and because any Pacman package (both MSYS2 and MinGW-w64 ones) may use MSYS2's bash to run a post-install script, issuing this command can cause these scripts to fail to run should any updated, core MSYS2 DLLs end up in a different location to where they were. For this reason, the safest procedure for updating MSYS2 is to do it in two stages;

首先更新MSYS2核心程序包:

pacman -S --needed filesystem msys2-runtime bash libreadline libiconv libarchive libgpgme libcurl pacman ncurses libintl

 

如果这一步更新了一些软件包,那么就需要关闭 msys2 然后再重新运行如下两个批处理文件:

autorebase.bat

msys2_shell.bat

否则更新其他软件包是会报错。(看来MSYS2 还是有点弱,希望以后能够把这个问题改好了)

之后就可以用:

pacman -Su

更新系统的其他软件包了。

列出所有安装了的软件

pacman -Q --explicit

或者

pacman -Q -e

安装新的软件包

pacman -S <package_names|package_groups>

比如我要安装 gcc。那么执行:

pacman -S gcc 

然后按照提示安装就可以了。

搜索软件包

很多时候,我们不知道要按照的软件的准确名称,这时就要先查询软件包的名称。

pacman -Ss <name_pattern>

 

比如我想安装gcc相关的软件,那么可以这样搜索

pacman -Ss gcc

 

pacman -Q --groups

可以列出所有的软件组,在我这里执行的结果如下:

base bash

base bash-completion

base bsdcpio

base bsdtar

base bzip2

base catgets

base coreutils

base crypt

base curl

base dash

base file

base filesystem

base findutils

base flex

base gawk

base gcc-libs

base getopt

base grep

base gzip

base less

base lndir

base man-db

base mintty

base msys2-runtime

base ncurses

base pacman

base pacman-mirrors

base pkgfile

base rebase

base sed

base texinfo

base tzcode

base which

msys2-devel binutils

msys2-devel gcc

msys2-devel msys2-w32api-headers

msys2-devel msys2-w32api-runtime

compression bzip2

compression gzip

compression liblzo2

compression xz

libraries cloog

libraries gmp

libraries heimdal-libs

libraries icu

libraries isl

libraries libarchive

libraries libasprintf

libraries libbz2

libraries libcares

libraries libcatgets

libraries libcrypt

libraries libcurl

libraries libdb

libraries libexpat

libraries libffi

libraries libgdbm

libraries libgettextpo

libraries libgpg-error

libraries libgpgme

libraries libiconv

libraries libidn

libraries libintl

libraries liblzma

libraries liblzo2

libraries libmetalink

libraries libnettle

libraries libopenssl

libraries libp11-kit

libraries libpcre

libraries libpipeline

libraries libreadline

libraries libsqlite

libraries libssh2

libraries libtasn1

libraries libxml2

libraries mpc

libraries mpfr

libraries zlib

Database db

Database gdbm

base-devel file

base-devel flex

base-devel gawk

base-devel gettext

base-devel grep

base-devel groff

base-devel m4

base-devel pacman

base-devel perl

base-devel pkgfile

base-devel sed

base-devel texinfo

MSYS2-devel msys2-runtime-devel

 

删除一个软件包

pacman -R <package_names|package_groups>


  • 4
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值