Chocolatey is the package manager for Windows.
You can install the msys2 environment with chocolatey, and install mingw in msys2.
- Open the Windows Powershell with administration user.
- Run the install script from Chocolatey.
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
- Run
choco install -y msys2
-
Close Powershell and open the directory
C:\tools\msys64\etc\pacman.d
-
There are three mirror files in it:
- mirrorlist.mingw32
- mirrorlist.mingw64
- mirrorlist.msys
Open and delete every line of them except the line with
https://mirrors.tuna.tsinghua.edu.cn
-
Open msys2 by
C:\tools\msys64\msys2.exe
-
Refresh the pacman database
pacman -Sy
- Install the mingw toolchain and some other utils in msys2
pacman -S mingw-w64-x86_64-toolchain libraries development compression VCS sys-utils net-utils msys2-devel mingw-w64-x86_64-cmake
You may check https://www.jianshu.com/p/c740b71e7775 for reference.