Skip to content

环境搭建(CLion,MSVC,MinGW)

安装 msys2

下载地址:https://www.msys2.org/

配置源,修改 /msys64/etc/pacman.d 文件夹如下三个文件

mirrorlist.mingw32

bash
##
## 32-bit Mingw-w64 repository mirrorlist
##

## Primary
## Server = https://repo.msys2.org/mingw/i686/
## Mirrors
## Server = https://downloads.sourceforge.net/project/msys2/REPOS/MINGW/i686/
## Server = https://www2.futureware.at/~nickoe/msys2-mirror/mingw/i686/
## Server = https://mirror.yandex.ru/mirrors/msys2/mingw/i686/
Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/i686/
Server = http://mirrors.ustc.edu.cn/msys2/mingw/i686/
## Server = http://mirror.bit.edu.cn/msys2/mingw/i686/
## Server = https://mirror.selfnet.de/msys2/mingw/i686/
## Server = https://mirrors.sjtug.sjtu.edu.cn/msys2/mingw/i686/
## Server = https://mirror.jmu.edu/pub/msys2/mingw/i686/
## Server = https://ftp.cc.uoc.gr/mirrors/msys2/mingw/i686/
## Server = https://ftp.acc.umu.se/mirror/msys2.org/mingw/i686/
## Server = https://mirrors.piconets.webwerks.in/msys2-mirror/mingw/i686/
## Server = https://quantum-mirror.hu/mirrors/pub/msys2/mingw/i686/
## Server = https://mirrors.dotsrc.org/msys2/mingw/i686/
## Server = https://mirror.ufro.cl/msys2/mingw/i686/
## Server = https://mirror.clarkson.edu/msys2/mingw/i686/
## Server = https://ftp.nluug.nl/pub/os/windows/msys2/builds/mingw/i686/
## Server = https://download.nus.edu.sg/mirror/msys2/mingw/i686/
## Server = https://ftp.osuosl.org/pub/msys2/mingw/i686/
## Server = https://fastmirror.pp.ua/msys2/mingw/i686/

mirrorlist.mingw64

bash
##
## 64-bit Mingw-w64 repository mirrorlist
##

## Primary
## Server = https://repo.msys2.org/mingw/x86_64/
## Mirrors
## Server = https://downloads.sourceforge.net/project/msys2/REPOS/MINGW/x86_64/
## Server = https://www2.futureware.at/~nickoe/msys2-mirror/mingw/x86_64/
## Server = https://mirror.yandex.ru/mirrors/msys2/mingw/x86_64/
Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/x86_64/
Server = http://mirrors.ustc.edu.cn/msys2/mingw/x86_64/
## Server = http://mirror.bit.edu.cn/msys2/mingw/x86_64/
## Server = https://mirror.selfnet.de/msys2/mingw/x86_64/
## Server = https://mirrors.sjtug.sjtu.edu.cn/msys2/mingw/x86_64/
## Server = https://mirror.jmu.edu/pub/msys2/mingw/x86_64/
## Server = https://ftp.cc.uoc.gr/mirrors/msys2/mingw/x86_64/
## Server = https://ftp.acc.umu.se/mirror/msys2.org/mingw/x86_64/
## Server = https://mirrors.piconets.webwerks.in/msys2-mirror/mingw/x86_64/
## Server = https://quantum-mirror.hu/mirrors/pub/msys2/mingw/x86_64/
## Server = https://mirrors.dotsrc.org/msys2/mingw/x86_64/
## Server = https://mirror.ufro.cl/msys2/mingw/x86_64/
## Server = https://mirror.clarkson.edu/msys2/mingw/x86_64/
## Server = https://ftp.nluug.nl/pub/os/windows/msys2/builds/mingw/x86_64/
## Server = https://download.nus.edu.sg/mirror/msys2/mingw/x86_64/
## Server = https://ftp.osuosl.org/pub/msys2/mingw/x86_64/
## Server = https://fastmirror.pp.ua/msys2/mingw/x86_64/

mirrorlist.msys

bash
##
## MSYS2 repository mirrorlist
##

## Primary
## Server = https://repo.msys2.org/msys/$arch/
## Mirrors
## Server = https://downloads.sourceforge.net/project/msys2/REPOS/MSYS2/$arch/
## Server = https://www2.futureware.at/~nickoe/msys2-mirror/msys/$arch/
## Server = https://mirror.yandex.ru/mirrors/msys2/msys/$arch/
Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/msys/$arch/
Server = http://mirrors.ustc.edu.cn/msys2/msys/$arch/
## Server = http://mirror.bit.edu.cn/msys2/msys/$arch/
## Server = https://mirror.selfnet.de/msys2/msys/$arch/
## Server = https://mirrors.sjtug.sjtu.edu.cn/msys2/msys/$arch/
## Server = https://mirror.jmu.edu/pub/msys2/msys/$arch/
## Server = https://ftp.cc.uoc.gr/mirrors/msys2/msys/$arch/
## Server = https://ftp.acc.umu.se/mirror/msys2.org/msys/$arch/
## Server = https://mirrors.piconets.webwerks.in/msys2-mirror/msys/$arch/
## Server = https://quantum-mirror.hu/mirrors/pub/msys2/msys/$arch/
## Server = https://mirrors.dotsrc.org/msys2/msys/$arch/
## Server = https://mirror.ufro.cl/msys2/msys/$arch/
## Server = https://mirror.clarkson.edu/msys2/msys/$arch/
## Server = https://ftp.nluug.nl/pub/os/windows/msys2/builds/msys/$arch/
## Server = https://download.nus.edu.sg/mirror/msys2/msys/$arch/
## Server = https://ftp.osuosl.org/pub/msys2/msys/$arch/
## Server = https://fastmirror.pp.ua/msys2/msys/$arch/

运行/msys64/msys2.exe

bash
# 类似于Ubuntu update语句
$ pacman -Su

# 安装开发工具
$ pacman -Sy base-devel

# Mingw-w64编译工具
$ pacman -S mingw-w64-x86_64-toolchain

安装 Mingw-w64

下载地址:https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/

添加系统环境变量

image.png

打印验证

image.png

CLion

image.png

image.png

image.png