网站极简设计,建立公司需要什么,范湖网站建设哪家便宜,wordpress中怎么排序文章目录 为什么用这个msys2下载、doc安装#xff0c;很简单初次运行#xff0c;做些配置更新软件安装与卸载方法安装必要的软件包设置win环境变量在windows terminal中使用在vscode中使用 为什么用这个msys2
方便windows上的C开发demo#xff0c;不需要VS了方便C开发安装o… 文章目录 为什么用这个msys2下载、doc安装很简单初次运行做些配置更新软件安装与卸载方法安装必要的软件包设置win环境变量在windows terminal中使用在vscode中使用 为什么用这个msys2
方便windows上的C开发demo不需要VS了方便C开发安装opencv等三方库有了这个就不需要另外安装git, cmake, mingw64了都可以通过pacman包管理工具一键安装
下载、doc
官网 https://www.msys2.org/ 官方文档 https://www.msys2.org/docs/terminals/ github https://github.com/msys2/msys2-installer/releases/
根据github readme中的说明也许自解压包是个更好的选择更加干净
这个msys2更新还挺活跃的最新是2023.5.26版本, 软件本体只有84Mnice
安装很简单
双击安装。安装过程基本上就是在解压安装过程信息如下到最后Updating trust database…的时候可能会卡住此时进度50%等着或者尝试翻墙
正在准备安装…正在准备解压组件......正在解压组件......
正在提取“20230526msys64.7z”
已完成正在安装组件 MSYS2
Copying skeleton files.
These files are for the users to personalise their msys2 experience.They will never be overwritten nor automatically updated../.bashrc - /home/username2/.bashrc
./.bash_logout - /home/username2/.bash_logout
./.bash_profile - /home/username2/.bash_profile./.profile - /home/username2/.profileC:\windows\system32\drivers\etc\hosts - /etc/hostsC:\windows\system32\drivers\etc\protocol - /etc/protocolsC:\windows\system32\drivers\etc\services - /etc/servicesC:\windows\system32\drivers\etc\networks - /etc/networks Generating pacman master key. This may take some time. Updating trust database... Appending keys from msys2.gpg... Locally signing trusted keys in keyring...- Locally signed 5 keys.Importing owner trust values...Disabling revoked keys in keyring...- Disabled 4 keys.Updating trust database...[H[2J[3J
已完成
编写维护工具。安装已完成!初次运行做些配置
安装之后有好几个终端环境推荐使用的、默认打开的是ucrt64.exe我这里也用这个任务栏是这样的
配置如下这里刚开始用Notepad等编辑器编辑就行
修改home目录为C:/Users/username这个win目录 配置文件 /etc/nsswitch.conf修改db_home: windows cygwin desc修改后最好把安装位置/home/user/下的配置文件靠背到win home下比如.bashrc啥的修改后重新打开终端生效可pwd查看路径 更换为国内源 配置文件 /etc/pacman.d/下的修改 db_home: windows cygwin desc各个mirrorlist文件没必要都修改修改你需要用的环境即可。比如我用ucrt64则只需修改: mirrorlist.msys, mirrorlist.ucrt64如何修改把下面的国内源挪到上面修改后应该是直接生效的 关闭不需要的软件源搜索结果 配置文件 /etc/pacman.conf 修改翻到最下面把不需要的环境注释掉 # [clangarm64]
# Include /etc/pacman.d/mirrorlist.mingw
#
# [mingw32]
# Include /etc/pacman.d/mirrorlist.mingw
#
# [mingw64]
# Include /etc/pacman.d/mirrorlist.mingw[ucrt64]
Include /etc/pacman.d/mirrorlist.mingw# [clang32]
# Include /etc/pacman.d/mirrorlist.mingw
#
# [clang64]
# Include /etc/pacman.d/mirrorlist.mingw[msys]
Include /etc/pacman.d/mirrorlist.msys
更新
pacman -Syyu因为已经换源了速度会挺快 会自动刚更新msys软件本体和安装过的软件包。如果不想更新某个软件包可以在配置文件设置。
包管理工具是pacman, 也就是arch linux和manjaro linux的包管理工具所以有问题搜索的时候可以参考这两个发行版的解决方案
软件安装与卸载方法
一般的安装命令pacman -S 软件包名 进行安装卸载命令pacman -Rs 软件包名如何知道完整包名pacman -Ss 包名关键词比如vim pacman -Ss vim 下图就搜索到了两个前面粉红色的是环境tag优先安装ucrt64的尤其是gcmake啥的编译工具链最好用ucrt64但我不想用neovim就选下面的msys那个vim了红线就是完整包名安装即可pacman -S vim
安装必要的软件包 安装编译工具链pacman -S mingw-w64-ucrt-x86_64-toolchain 这里面包含很多东西gcc, g, make等都有了修改mingw32-make.exe文件名为make.exe cd /ucrt64/binln -s mingw32-make.exe make.exe 安装cmake: pacman -S mingw-w64-ucrt-x86_64-cmake 安装git: pacman -S git 安装其他需要的软件
设置win环境变量
上面安装的东西可执行文件一般在/ucrt64/bin/usr/bin/下把这两个加到系统PATH即可注意顺序这样你在非msys2终端环境中也能使用这里安装的软件了比如rm, vim啥的在msys2的终端环境中默认无法使用win环境变量的PATH, 有两种方式可以使用 方法1在win环境变量中添加一个新变量MSYS2_PATH_TYPE值为inherit方法2通过安装位置的msys2_shell.cmd启动并添加-full-path参数
在windows terminal中使用
官方doc https://www.msys2.org/docs/terminals/
修改windows terminal的配置json, 注意修改路径为你的安装位置
// This makes UCRT64 the default shell
defaultProfile: {17da3cac-b318-431e-8a3e-7fcdefe6d114},
profiles: {list:[// ...{guid: {17da3cac-b318-431e-8a3e-7fcdefe6d114},name: UCRT64 / MSYS2,commandline: C:/msys64/msys2_shell.cmd -defterm -here -no-start -ucrt64,startingDirectory: C:/msys64/home/%USERNAME%,icon: C:/msys64/ucrt64.ico,font: {face: Lucida Console,size: 9}},{guid: {71160544-14d8-4194-af25-d05feeac7233},name: MSYS / MSYS2,commandline: C:/msys64/msys2_shell.cmd -defterm -here -no-start -msys,startingDirectory: C:/msys64/home/%USERNAME%,icon: C:/msys64/msys2.ico,font: {face: Lucida Console,size: 9}},// ...]
}
在vscode中使用
官方文档 https://www.msys2.org/docs/ides-editors/
如下内容添加到vscode的settings.json, 注意修改路径为你的安装位置
{terminal.integrated.profiles.windows: {MSYS2 UCRT: {path: cmd.exe,args: [/c,C:\\msys64\\msys2_shell.cmd -defterm -here -no-start -ucrt64]}}
}