microsoft 出品的 cl编译器运行/调试c配置,cl.exe 通过visual studio c ++ build tools 安装:
launch.json:
1 { 2 "version": "0.2.0", 3 "configurations": [ 4 { // 对应cl.exe 5 "name": "cl.exe build and debug active file", 6 "type": "cppvsdbg", 7 "request": "launch", 8 "program": "${cwd}\out\${fileBasenameNoExtension}.exe", 9 "args": [], 10 "stopAtEntry": false, 11 "cwd": "${workspaceFolder}", 12 "environment": [], 13 "externalConsole": true, 14 "preLaunchTask": "cl.exe build active file", 15 "logging": { // 用于消除PDB文件找不到打不开问题,来自于https://none53.hatenablog.com/entry/2019/11/28/vsCode_Cannot_find_or_open_the_PDB_file. 16 "moduleLoad": false 17 }, 18 "presentation": { 19 "focus": true 20 } 21 } 22 ] 23 }
tasks.json: 需要在项目根目录建 out 文件夹
1 { 2 "version": "2.0.0", 3 "tasks": [ 4 { // 对应cl.exe 5 "type": "shell", 6 "label": "cl.exe build active file", 7 "command": "cl.exe", 8 "args": [ // cl的编译选项,自行设置 9 "/Zi", 10 "/EHsc", 11 "/Fe:", 12 "${cwd}\out\${fileBasenameNoExtension}.exe", 13 "/Fo:", 14 "${cwd}\out\${fileBasenameNoExtension}.obj", 15 "${file}" 16 ], 17 "group": { 18 "kind": "build", 19 "isDefault": true 20 }, 21 "presentation": { 22 "reveal": "always" 23 }, 24 "problemMatcher": "$msCompile" 25 }, 26 ] 27 }
Windows 环境变量 - >系统变量新建:
INCLUDE
值(按实际情况设置填值,这里是笔者安装Visual Studio 2019后的值):
C:Program Files (x86)Windows Kits10Include10.0.18362.0ucrt;C:Program Files (x86)Windows Kits10Include10.0.18362.0um;C:Program Files (x86)Windows Kits10Include10.0.18362.0winrt;C:Program Files (x86)Microsoft Visual Studio2019BuildToolsVCToolsMSVC14.27.29110include;C:Program Files (x86)Windows Kits10Lib10.0.18362.0ucrtx64;
LIB
值(按实际情况设置填值,这里是笔者安装Visual Studio 2019后的值):
C:Program Files (x86)Windows Kits10Lib10.0.18362.0ucrtx64;C:Program Files (x86)Windows Kits10Lib10.0.18362.0umx64;C:Program Files (x86)Microsoft Visual Studio2019BuildToolsVCToolsMSVC14.27.29110libx64;