引言
Windows环境下MSVC的在vscode中配置方法
1 MSVC的VsCode配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\winrt C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x64 C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\ucrt\x64 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64
|
1.1 使用MSVC的cl.exe进行构建
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| { "version": "2.0.0", "tasks": [ { "type": "cppbuild", "label": "MSVC build", "command": "cl.exe", "args": [ "/Zi", "/EHsc", "/nologo", "/Fe${fileDirname}\\${fileBasenameNoExtension}.exe", "${file}" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$msCompile" ], "group": { "kind": "build", "isDefault": true }, "detail": "MSVC Build" } ] }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| { "version": "0.2.0", "configurations": [ { "name": "MSVC Debug", "type": "cppvsdbg", "request": "launch", "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": true, "cwd": "${fileDirname}", "environment": [], "console": "externalTerminal", "externalConsole": false, "preLaunchTask": "MSVC build" }
] }
|
1.2 使用MSVC的cl.exe进行构建
-
CMake生成的文件在build/bin文件夹内
-
编写task.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| { "version": "2.0.0", "tasks": [ { "name": "MSVC Launch", "type": "cppvsdbg", "request": "launch", "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": true, "cwd": "${fileDirname}", "environment": [], "console": "externalTerminal", "externalConsole": false, "preLaunchTask": "C/C++: MSVC build" } ] }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| { "version": "0.2.0", "configurations": [ { "name": "CMake Launch", "type": "cppvsdbg", "request": "launch", "program": "${workspaceFolder}/build/bin/Debug/${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": true, "cwd": "${fileDirname}", "environment": [], "console": "externalTerminal", "externalConsole": false, } ] }
|