【已解决】cl.exe build and debug is only usable when VS Code is run from the Developer Command Prompt...
【已解决】关于 cl.exe build and debug is only usable when VS Code is run from the Developer Command Prompt for VS. 的问题。
Author:AXYZdong 硕士在读 工科男
有一点思考,有一点想法,有一点理性!定个小小目标,努力成为习惯!在最美的年华遇见更好的自己!
CSDN@AXYZdong,CSDN首发,AXYZdong原创
唯一博客更新的地址为: 👉 AXYZdong的博客 👈
B站主页为:AXYZdong的个人主页
问题描述
VSCode 丨关于 cl.exe build and debug is only usable when VS Code is run from the Developer Command Prompt for VS. 的问题。
使用 VSCode 运行C++文件,点击 Run C/C++ file
页面右下角出现以下报错:
翻译过来就是:仅当从 VS 开发人员命令提示符处运行 VS Code 时,cl.exe 生成和调试才可用。
解决方法
方法一:使用 cl.exe
编译与调试。
【参考:仅当从 VS 开发人员命令提示符处运行 VS Code 时,cl.exe 生成和调试才可用。】
在你的开始菜单找到 Developer Command Prompt for VS xxxx 快捷方式
中文名即 VS> 开发人员命令提示符
指向的是 VsDevCmd.bat在这里进入工程目录,用命令打开 vs code
code .
方法二:使用 gcc.exe
编译与调试。
① 安装 C/C++扩展插件。
② 安装 MinGW-x64
on Windows ,参考官方教程 C/C++ for Visual Studio Code。
③ 添加环境变量,在电脑的环境变量中添加mingw-w64的bin
文件夹路径。
④ 检查mingw-w64的安装,打开cmd窗口,分别输入下面两条指令:
g++ --version
gdb --version
③ ④ 步骤具体可参考 https://zhuanlan.zhihu.com/p/130711420。
⑤ 点击 Terminal -> Configure Default Build Task...
选择 C/C++: g++.exe build active file
。
最后再点击 Run C/C++ file
就不会报错啦~
⑥ Debug 配置
—— END ——
如果以上内容有任何错误或者不准确的地方,欢迎在下面 👇 留言。或者你有更好的想法,欢迎一起交流学习~~~
更多精彩内容请前往 AXYZdong的博客~
更多推荐
所有评论(0)