I am under windows10, using msys64 mingw64 terminal

Series Article Directory

foreword

msys2 official website

MSYS2 (Minimal SYStem 2) is an independent rewritten version of MSYS, mainly used in the shell command line development environment. It is also a Windows software based on Cygwin (POSIX compatibility layer) and MinGW-w64 (from "MinGW-generated") for better interoperability.
insert image description here

1. What is MSYS2?

MSYS2 is a collection of tools and libraries that give you an easy-to-use environment to build, install and run native Windows software.

It includes a command-line terminal called mintty, version control systems like bash, git, and subversion, tools like tar and awk, and even build systems like autotools, all based on modified versions of Cygwin. Although some core parts of it are based on Cygwin, the main focus of MSYS2 is to provide a build environment for native Windows software, and the use of Cygwin is kept to a minimum. MSYS2 provides the latest native builds for GCC, mingw-w64, CPython, CMake, Meson, OpenSSL, FFmpeg, Rust, Ruby, and more, just to name a few.

To provide an easy way to install packages and keep them updated, it offers a package management system called Pacman, which should be familiar to Arch Linux users. It brings many powerful features, such as dependency resolution and easy full system upgrades, to straightforward and reproducible package building. Our package repository contains more than 2800 pre-built packages ready to install.

For more information, see "What is MSYS2?" It also compares MSYS2 to other software distributions and development environments such as Cygwin, WSL, Chocolatey, Scoop, etc., and "Who is using MSYS2?" See what projects Using MSYS2 and what it does.

Installation
Download the installer: msys2-x86_64-20230318.exe

insert image description here

Verify using SHA256 checksum 051a523e645b40f34e9d80f245b42828410208b575b7502de068e65cba1d02d0 and or GPG signature via 0xf7a49b0ec.

Run the installer. MSYS2 requires 64-bit Windows 8.1 or newer.

Enter the desired installation folder (ASCII-only short path on NTFS volume, no accents, no spaces, no symbolic links, no subst or network drives, no FAT).

MSYS2 install second screen

When finished, click Finish.

MSYS2 install third screen

Now that MSYS2 is ready for you, the terminal for the UCRT64 environment will start.

Empty the MSYS2 terminal window

You may need to install some tools such as mingw-w64 GCC to start compiling:

$ pacman -S mingw-w64-ucrt-x86_64-gcc
resolving dependencies…
looking for conflicting packages…

Packages (15) mingw-w64-ucrt-x86_64-binutils-2.39-2
mingw-w64-ucrt-x86_64-crt-git-10.0.0.r68.g6eb571448-1
mingw-w64-ucrt-x86_64-gcc-libs-12.2.0-1 mingw-w64-ucrt-x86_64-gmp-6.2.1-3
mingw-w64-ucrt-x86_64-headers-git-10.0.0.r68.g6eb571448-1
mingw-w64-ucrt-x86_64-isl-0.25-1 mingw-w64-ucrt-x86_64-libiconv-1.17-1
mingw-w64-ucrt-x86_64-libwinpthread-git-10.0.0.r68.g6eb571448-1
mingw-w64-ucrt-x86_64-mpc-1.2.1-1 mingw-w64-ucrt-x86_64-mpfr-4.1.0.p13-1
mingw-w64-ucrt-x86_64-windows-default-manifest-6.4-4
mingw-w64-ucrt-x86_64-winpthreads-git-10.0.0.r68.g6eb571448-1
mingw-w64-ucrt-x86_64-zlib-1.2.12-1 mingw-w64-ucrt-x86_64-zstd-1.5.2-2
mingw-w64-ucrt-x86_64-gcc-12.2.0-1

Total Installed Size: 397.59 MiB

:: Proceed with installation? [Y/n]
[… downloading and installation continues …]
Now you can invoke gcc to build software for Windows.

$ gcc --version
gcc.exe (Rev1, Built by MSYS2 project) 12.2.0
After installing MSYS2, it will update itself via pacman, see the update guide for more information.

The purpose of entering these two commands in the msys64 mingw64 terminal is to add the /mingw64/bin directory to the system environment variable PATH, so that the programs in this directory can be directly run in the terminal.

echo 'export PATH=/mingw64/bin: PATH ′ > > / . bashrc : This command converts the string ′ export PATH = / mingw 64 / bin : PATH' >> ~/.bashrc: This command converts the string ' export PATH=/mingw64/bin:PATH>> /.ba s h rc : This command converts the stringexportPATH=/mingw64/bin: PATH' is appended to the current user's ~/.bashrc file. The .bashrc file is a special file that contains settings and commands that should be run when the Bash shell is started. Here we have added a command to tell the system to include the /mingw64/bin directory when looking for executable programs.

source ~/.bashrc:
This command will immediately run all the commands in the ~/.bashrc file to make the changes we just made take effect. After executing source ~/.bashrc, the system will re-read the settings in the .bashrc file and add the /mingw64/bin directory to the environment variable PATH.

Through these two commands, you can directly run the programs in the /mingw64/bin directory in the msys64 mingw64 terminal, without entering the complete path every time. This is useful for command-line tools that are frequently used during compilation and development.

insert image description here

Guess you like

Origin blog.csdn.net/aoxuestudy/article/details/130120900