配置代码如下
properities
{ "configurations": [ { "name": "Win32", "includePath": [ "${workspaceFolder}/**" ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], "windowsSdkVersion": "10.0.19041.0", "compilerPath": "D:/Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe", "cStandard": "c17", "cppStandard": "c++17", "intelliSenseMode": "windows-msvc-x64" } ], "version": 4 }
task
{ "configurations": [ { "name": "Win32", "includePath": [ "${workspaceFolder}/**" ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], "windowsSdkVersion": "10.0.19041.0", "compilerPath": "D:/Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe", "cStandard": "c17", "cppStandard": "c++17", "intelliSenseMode": "windows-msvc-x64" } ], "version": 4 }
错误提示
> Executing task: C/C++: cl.exe 生成活动文件 < 正在启动生成... cl.exe /Zi /EHsc /nologo /Fe: a1.exe a1.cpp 'cl.exe' е 生成已完成,但出现错误. 终端进程启动失败(退出代码: -1)。 终端将被任务重用,按任意键关闭。
当我使用 vs2019 的 devtools 输入cl a1.cpp
的时候,a1.exe 和 a1.obj 正常生成和运行,但当使用 vscode 内的 ctrl+shift+b 的时候显示上述错误信息
参考的教程 https://blog.csdn.net/qq_38981614/article/details/99629597
task贴错了 是这个
{ "version": "2.0.0", "tasks": [ { "type": "cppbuild", "label": "C/C++: cl.exe 生成活动文件", "command": "cl.exe", "args": [ "/Zi", "/EHsc", "/nologo", "/Fe:", "a1.exe", "a1.cpp" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$msCompile" ], "group": { "kind": "build", "isDefault": true }, "detail": "编译器: cl.exe" } ] }
![]() | 1 ysc3839 2021-09-17 09:37:04 +08:00 via Android 你确定 task 的内容是对的?为什么跟 properities 一样? |
![]() | 2 misakawaque OP @ysc3839 啊是的,贴错了 |
![]() | 3 ysc3839 2021-09-17 10:31:53 +08:00 task 里面的 command 写完整路径试试? |
![]() | 4 misakawaque OP @ysc3839 将 command 修改为了"command": "D:/Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe" 但是错误报告没有变化仍显示 > Executing task: C/C++: cl.exe 生成活动文件 < 正在启动生成... cl.exe /Zi /EHsc /nologo /Fe: a1.exe a1.cpp 'cl.exe' е 生成已完成,但出现错误. 终端进程启动失败(退出代码: -1)。 |
![]() | 5 misakawaque OP |
![]() | 6 ysc3839 2021-09-17 11:26:37 +08:00 @misakawaque 看上去修改后并没有生效,我也不知道是什么问题了…… |
![]() | 7 kokutou 2021-09-17 12:20:30 +08:00 via Android 改改编码,搞清楚那堆乱码报错信息说的是啥 |
9 mangohaoming 2021-09-17 13:40:01 +08:00 一键安装 C/C++ extension pack 插件解君愁,当然前提是得使用 cmake |
![]() | 10 Vinty 2021-09-17 14:25:22 +08:00 估计是标准库的 include 或者 library 的路径没有 用 cl 命令行,要在 msvc 的 prompt 环境里面启动 vscode |
![]() | 11 misakawaque OP @Vinty 只能开着那个黑框来用么 |
![]() | 12 Vinty 2021-09-18 11:12:10 +08:00 @misakawaque #11 就按照 csdn 那个教程里面的方式,在 vs prompt 里面启动 vscode 就可以了 vscode 官方文档也是这样做的 https://code.visualstudio.com/docs/cpp/config-msvc 就是是通过 vcvars.bat 设置了一些环境变量,大概主要是 INCLUDE LIB LIBPATH,可能把这些变量手动添加一下应该也可以。 还有 cpp_properties.json 只是 IntelliSense 的配置,对编译和链接并没有作用 |