如何使用 MSYS2 编译最新版的 coreutils 源码(目前最新版本为 coreutils-9.4)

本文详细介绍了如何在MSYS2环境中编译coreutils的最新版本9.4。首先从官方镜像仓库下载源码,接着通过pacman更新软件仓库,安装必要的编译工具如gcc和make。在编译过程中,由于cygwin-3.4.8的bug导致编译错误,但已在3.4.9版本修复。文章提供了修改msys2-runtime配置文件以解决此问题的方法,并安装所有依赖项以完成编译。最终成功编译出可执行程序并测试了其功能。
摘要由CSDN通过智能技术生成

上一篇文章总结了: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%
(
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小青龍

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值