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>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章