vscode C语言cl编译器调试配置

microsoft 出品的 cl编译器运行/调试c配置,cl.exe 通过visual studio c ++ build tools 安装:

 

安装或者安装失败可以看教程:https://blog.csdn.net/HaoZiHuang/article/details/125795675

 

launch.json:

 

2021-08-22:新版本vscode 已经将 externalConsole 配置项标记为废弃,更换为使用使用:  "console": "integratedTerminal",

 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             "console": "integratedTerminal",
         "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         {    
 5             "type": "shell",
 6             "label": "cl.exe build active file",
 7             "command": "cl.exe",
 8             "args": [  
 9                 "/Zi",
10                 "/source-charset:utf-8",  // 源文件编码,加上此行可以在文件中写中文注释也不会有IDE warning信息
11                 "/EHsc",
12                 "/Fe:",
13                 "${cwd}\\out\\${fileBasenameNoExtension}.exe",
14                 "/Fo:",
15                 "${cwd}\\out\\${fileBasenameNoExtension}.obj",
16                 "${file}"
17             ],
18             "group": {
19                 "kind": "build",
20                 "isDefault": true
21             },
22             "presentation": {
23                 "reveal": "always"
24             },
25             "problemMatcher": "$msCompile"
26         }
27     ]
28 }

 

 

Windows 环境变量 - >系统变量新建:

INCLUDE

值(按实际情况设置填值,这里是笔者安装Visual Studio 2019后的值):

 

C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\winrt;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64;

 

LIB

值(按实际情况设置填值,这里是笔者安装Visual Studio 2019后的值):

 

C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\lib\x64;

 

posted @ 2020-09-28 10:35  Joynic  阅读(1165)  评论(0编辑  收藏  举报