MSYS2教程(windows环境下使用linux工具)

MSYS2教程(windows环境下使用linux工具)

1.msys2简介

MSYS2(Minimal SYStem 2)是一个集成了大量的GNU工具链、工具和库的开源软件包集合。它提供了一个类似于Linux的shell环境,可以在Windows系统中编译和运行许多Linux应用程序和工具。

MSYS2基于MinGW-w64平台,提供了一个完整的开发环境,包括GCC编译器、GDB调试器、Make、Git版本控制系统和许多其他开发工具。除了常用的开发库和工具之外,MSYS2还提供了许多专门针对Windows平台的库和工具,方便开发人员进行跨平台开发和移植工作。

使用MSYS2可以轻松地在Windows系统中搭建一个类似于Linux的软件开发环境,方便开发人员进行开发和调试工作。

https://www.msys2.org/

2.安装

双击msys2-x86_64-20240507.exe进行安装。

shell 复制代码
Preparing the installation...

Preparing to unpack components...

Unpacking components...
Extracting "20240507msys64.7z"
Done

Installing component MSYS2
Copying skeleton files.

These files are for the users to personalise their msys2 experience.



They will never be overwritten nor automatically updated.


'./.bashrc' -> '/home/Administrator/.bashrc'

'./.bash_logout' -> '/home/Administrator/.bash_logout'

'./.bash_profile' -> '/home/Administrator/.bash_profile'

'./.profile' -> '/home/Administrator/.profile'

'C:\WINDOWS\system32\drivers\etc\hosts' -> '/etc/hosts'

'C:\WINDOWS\system32\drivers\etc\protocol' -> '/etc/protocols'

'C:\WINDOWS\system32\drivers\etc\services' -> '/etc/services'

'C:\WINDOWS\system32\drivers\etc\networks' -> '/etc/networks'

==> Generating pacman master key. This may take some time.

==> Updating trust database...

==> Appending keys from msys2.gpg...

==> Locally signing trusted keys in keyring...

  -> Locally signed 5 keys.

==> Importing owner trust values...

==> Disabling revoked keys in keyring...

  -> Disabled 4 keys.

==> Updating trust database...

[H[2J[3J
Done
Writing maintenance tool.

Installation finished!

==> Updating trust database...这个地方会卡3~5分钟,如果继续卡住,可以断网。

如果想看这个地方是在做什么操作,可以使用命令行安装:

shell 复制代码
msys2-x86_64-20240507.exe in --confirm-command --accept-messages --root D:/msys64

3.使用

MSYS2 软件发行版使用pacman管理(安装、删除和更新)二进制包。

启动:

进入安装目录D:\msys64,双击

shell 复制代码
mingw64.exe

帮助:

$ pacman -h
usage:  pacman <operation> [...]
operations:
    pacman {-h --help}
    pacman {-V --version}
    pacman {-D --database} <options> <package(s)>
    pacman {-F --files}    [options] [file(s)]
    pacman {-Q --query}    [options] [package(s)]
    pacman {-R --remove}   [options] <package(s)>
    pacman {-S --sync}     [options] [package(s)]
    pacman {-T --deptest}  [options] [package(s)]
    pacman {-U --upgrade}  [options] <file(s)>

use 'pacman {-h --help}' with an operation for available options

更新:

shell 复制代码
pacman -Suy

输入Y后会关闭窗口。

查找:

shell 复制代码
pacman -Ss <name or part of the name of the package>

例如:

shell 复制代码
pacman -Ss openjp

如果只想在已安装的软件包中搜索**,**请使用以下命令:

pacman -Qs <name or part of the name of the package>

例如:

shell 复制代码
pacman -Qs openjp
#列出所有安装的包
pacman -Q

列出包的内容

shell 复制代码
pacman -Ql <name of the package>

例如:

shell 复制代码
pacman -Ql xz

4.相关文件

shell 复制代码
D:\msys64\usr\bin
D:\msys64\mingw64\bin
相关推荐
likfishdn9 分钟前
Linux的文件与目录管理
linux·运维·服务器
chian-ocean29 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=30 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
追寻光1 小时前
Cannot find a valid baseurl for repo: base/7/x86_64
linux
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
陆沙1 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos
北京耐用通信1 小时前
航空装配自动化神器Ethercat转profient网关搭配机器人精准控制
运维·机器人·自动化
吃汤圆的抹香鲸2 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net
sz66cm2 小时前
Linux基础 -- ARM 32 位架构动态注入代码技术文档
linux·arm开发·架构