ILD

MSYS2的几个运行环境
作者:Yuan Jianpeng 邮箱:yuanjp89@163.com
发布时间:2026-8-20 站点:Inside Linux Development

装完windows,会发现有几个运行图标


他们有什么区别呢?

其实主要是toolchain的区别。对于工具没有区别。MSYS2的目标是构建运行在windows的程序。

运行时,他们的环境变量不同,尤其是PATH。


MSYS2 MSYS

这个主要是提供工具。不提供toolchain

PATH:

/usr/local/bin:/usr/bin:/bin:/opt/bin:/c/Windows/System32:/c/Windows:

/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:

/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl


MSYS2 UCRT64

编译器:mingw-w64-ucrt-x86_64-gcc

C运行时:UCRT

PATH:

/ucrt64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:

/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:

/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl


MSYS2 CLANG

编译器:Clang/LLVM

C运行时:UCRT


MSYS2 MINGW64

编译器:mingw-w64-x86_64-gcc

C运行时:MSVCRT

PATH

/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:

/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:

/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl


首选 UCRT64:如果你是初次接触 MSYS2 的开发者,或者希望获得最稳定、兼容性最广的开发体验,官方文档的明确建议是选择 UCRT64 环境


在 MSYS2 中,UCRT64 是当前官方推荐、用于现代 Windows 开发的主力环境,而 MINGW64 则是一个基于老旧运行时、已被官方标记为“弃用”的经典环境。简单来说,UCRT64 是未来的方向,MINGW64 是正在被取代的过去。


注意:

在任何一个环境使用pacman安装包都是可以的,都能安装到正确的路径。

比如在CLANG里面安装:

$ pacman -S mingw-w64-ucrt-x86_64-gcc

会安装到/ucrt64目录。只能在UCRT环境使用


Copyright © linuxdev.cc 2017-2024. Some Rights Reserved.