目标:
windows上使用visual stdio编码(c++),然后跨平台在windows和linux上分别运行
需要安装的软件:
windows11: 安装wsl2,安装visual stdio2022(或者其他版本)
一,通过windows11安装wsl2
参考:旧版 WSL 的手动安装步骤 | Microsoft Learn
提取关键步骤
1.启用适用于 Linux 的 Windows 子系统:打开powershell并输入,以管理员身份运行:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
2.启用虚拟化:以管理员打开powershell输入下列命令
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
3.下载X64的WSL2 Linux内核升级包并安装
https://link.zhihu.com/?target=https%3A//wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
4.设置WSL默认版本
wsl --set-default-version 2