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>

 

http://blog.csdn.net/liyuanbhu/article/details/39397931


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM