上一篇文章总结了:MSYS2 介绍、下载与安装、Pacman常用命令
本文将演示如何使用 MSYS2 编译 coreutils 源码。
一、coreutils 源码下载
官网镜像仓库:Index of /gnu/coreutils
Github 仓库:coreutils/coreutils/tags
这里下载目前最新版本:coreutils-9.4.tar.gz
虽然但是我还是要提一下:MSYS2 安装完成后,默认会安装coreutils软件包,版本为 8.32
Administrator@GC MSYS ~
$ pacman -Qs coreutils
local/coreutils 8.32-5
The basic file, shell and text manipulation utilities of the GNU operating system
一般情况下也没必要使用最新版,这里仅是为了演示如何使用MSYS2编译项目,所以就拿coreutils试试。
二、MSYS2 安装编译工具
使用 MSYS 环境进行编译 coreutils
1. pacman -Suy 更新软件仓库
Administrator@GC MSYS ~
$ pacman -Suy
:: Synchronizing package databases...
clangarm64 is up to date
mingw32 is up to date
mingw64 is up to date
ucrt64 is up to date
clang32 is up to date
clang64 is up to date
msys is up to date
:: Starting core system upgrade...
there is nothing to do
:: Starting full system upgrade...
there is nothing to do
我这里已经是最新了。
2. pacman -S msys/gcc 安装gcc
Administrator@GC MSYS ~
$ pacman -S msys/gcc
resolving dependencies...
looking for conflicting packages...
Packages (8) binutils-2.41-2 isl-0.26-1 mpc-1.3.1-1 msys2-runtime-devel-3.4.8-1
msys2-w32api-headers-11.0.1.r0.gc3e587c06-1
msys2-w32api-runtime-11.0.1.r0.gc3e587c06-1 windows-default-manifest-6.4-1
gcc-11.3.0-4
Total Download Size: 41.38 MiB
Total Installed Size: 318.84 MiB
:: Proceed with installation? [Y/n] y
:: Retrieving packages...
isl-0.26-1-x86_64 745.0 KiB 260 KiB/s 00:03 [###############################] 100%
msys2-w32api-headers-11.0.... 5.2 MiB 1131 KiB/s 00:05 [###############################] 100%
mpc-1.3.1-1-x86_64 78.5 KiB 147 KiB/s 00:01 [###############################] 100%
binutils-2.41-2-x86_64 5.4 MiB 979 KiB/s 00:06 [###############################] 100%
windows-default-manifest-6... 1388.0 B 3.45 KiB/s 00:00 [###############################] 100%
msys2-runtime-devel-3.4.8-... 338.8 KiB 68.2 KiB/s 00:05 [###############################] 100%
gcc-11.3.0-4-x86_64 27.6 MiB 2.63 MiB/s 00:10 [###############################] 100%
msys2-w32api-runtime-11.0.... 2.0 MiB 194 KiB/s 00:11 [###############################] 100%
Total (8/8) 41.4 MiB 3.86 MiB/s 00:11 [###############################] 100%
(8/8) checking keys in keyring [###############################] 100%
(8/8) checking package integrity [###############################] 100%
(8/8) loading package files [###############################] 100%
(8/8) checking for file conflicts [###############################] 100%
(8/8) checking available disk space [###############################] 100%
:: Processing package changes...
(1/8) installing binutils [###############################] 100%
(2/8) installing isl [###############################] 100%
(3/8) installing mpc [###############################] 100%
(4/8) installing msys2-runtime-devel [###############################] 100%
(5/8) installing msys2-w32api-headers [###############################] 100%
(6/8) installing msys2-w32api-runtime [###############################] 100%
(