msys2¶
MSYS2 为 GCC、Mingw-W64、CPython、CMake、Meson、openssl、FFmpeg、Rust、Ruby 等提供了最新的本机构建。通过它,我们可以在 windows 上使用上面这些工具。
- 官网
以下安装都是安装 ucrt 版本的, 安装的工具将保存在 C:\msys64\ucrt64\bin
目录,所以将 C:\msys64\ucrt64\bin
目录加入 path 路径中,我们就能够使用安装的工具了。
1 安装 gcc 相关工具包¶
主要包括 gcc、gdb、make 工具。 启动 C:\msys64\ucrt64.exe, 执行如下命令进行安装:
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
控制台可能输出如下,按 enter 即可:
resolving dependencies...
looking for conflicting packages...
Packages (15) mingw-w64-ucrt-x86_64-binutils-2.41-2
mingw-w64-ucrt-x86_64-crt-git-11.0.0.r216.gffe883434-1
mingw-w64-ucrt-x86_64-gcc-libs-13.2.0-2 mingw-w64-ucrt-x86_64-gmp-6.3.0-2
mingw-w64-ucrt-x86_64-headers-git-11.0.0.r216.gffe883434-1
mingw-w64-ucrt-x86_64-isl-0.26-1 mingw-w64-ucrt-x86_64-libiconv-1.17-3
mingw-w64-ucrt-x86_64-libwinpthread-git-11.0.0.r216.gffe883434-1
mingw-w64-ucrt-x86_64-mpc-1.3.1-2 mingw-w64-ucrt-x86_64-mpfr-4.2.1-2
mingw-w64-ucrt-x86_64-windows-default-manifest-6.4-4
mingw-w64-ucrt-x86_64-winpthreads-git-11.0.0.r216.gffe883434-1
mingw-w64-ucrt-x86_64-zlib-1.3-1 mingw-w64-ucrt-x86_64-zstd-1.5.5-1
mingw-w64-ucrt-x86_64-gcc-13.2.0-2
Total Download Size: 49.38 MiB
Total Installed Size: 418.82 MiB
:: Proceed with installation? [Y/n]
[... downloading and installation continues ...]
也可以单独安装需要的工具,见下面。
2 安装 gcc¶
$ pacman -S mingw-w64-ucrt-x86_64-gcc
3 安装 gdb¶
$ pacman -S mingw-w64-ucrt-x86_64-gdb
4 安装 make¶
$ pacman -S mingw-w64-ucrt-x86_64-make
5 安装 cppcheck¶
$ pacman -S mingw-w64-ucrt-x86_64-cppcheck