天天看點

msys2 安裝筆記(轉)msys2 安裝筆記

msys2 安裝筆記

2014年09月19日 14:44:45 liyuanbhu 閱讀數:36173更多

個人分類: 程式設計雜項

以前一直在用 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>