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。有了包管理系统,升级、安装新的软件就非常easy了。 只是我一直在用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>


版权声明:本文博客原创文章。博客,未经同意,不得转载。

原文地址:https://www.cnblogs.com/mfrbuaa/p/4649292.html