VS Code 问题:launch:program‘...\.vscode\launch.exe‘ dose not exist

VS Code 问题:launch:program'...\.vscode\launch.exe' dose not exist

问题描述

按照博客大佬们的指导,给 VS Code 配置 C++ 语言环境,参考推荐:菜得扣↑的博客。根据指导,配置了 launch.jsontask.jsonc_cpp_properties.json 三个文件。运行.cpp文件时报错。

在这里插入图片描述

原图来自:https://www.pianshen.com/article/56791875146/

解决过程

根据问题描述,查找 “launch:program’…vscode\launch.exe’ dose not exist” 相关解决办法。浏览众多博客,解决方式主要围绕在确认launch.jsontasks.json的相关内容是否统一上,主要包括:

  1. 确认tasks.json中的labellaunch.json中的preLaunchTask是否统一。此处的设置多种多样,只需要保证两者统一即可。参考博客3
  2. tasks.json文件中的command设置为g++参考博客4。按照此前的配置博客配置后,我此处为"C:\\TDM-GCC-64\\bin\\g++.exe",指向g++编译器。
  3. 修改task.jsonargslaunch.jsonprogram的设置,将${workspaceFloder}修改为${fileBasenameNoExtension}参考博客5

仔细查看了自己的配置文件,如下:

launch.json

 {
    
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe - 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,//弹出控制台窗口
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\TDM-GCC-64\\bin\\gdb.exe",//自己调试器位置
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ]
}

tasks.json

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "shell",
			"label": "C/C++: g++.exe build active file",
			"command": "C:\\TDM-GCC-64\\bin\\g++.exe",
			"args": [
				"-g",
				"${file}",
				"-o",
				"${fileDirname}\\${fileBasenameNoExtension}.exe"
			],
			"options": {
				"cwd": "${workspaceFolder}"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": {
				"kind": "test",
				"isDefault": true
			}
		}
	]
}

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\TDM-GCC-64\\bin\\gcc.exe",
            "cStandard": "c11",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

确认三个文档的内容都没有问题。于是,又重新浏览了一边配置流程,发现一个问题:在配置c_cpp_properties.json之前,.cpp文件就编译为了.exe所以问题不在配置文档中的设置,而在于编译器的选择。搜索 “VS Code无法将.cpp编译为.exe”,找到示好的博客。问题出在shell上。

好吧,这一句 “Hello world !” 真难说出口。

参考内容

  1. 菜得扣↑. VScode配置C/C++环境简单教程(2分钟). CSDN博客
  2. 解决VSCode出现“launch: program … does not exist”的问题. 程序员大本营
  3. Takai达达君. Visual Studio Code(VS Code) 配置 C/C++ 环境常见问题及解决方案. CSDN博客
  4. 核聚变Q. VS Code,launch:program ‘路径…exe‘dose not exsit,undefined reference to `std::cout‘. CSDN博客
  5. 星空凛凛蝶. Visual studio code配置c++的运行环境中,出现launch:program’-路径-'does not exist(小白看这里). CSDN博客
  • 59
    点赞
  • 243
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 12
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

猎猫骑巨兽

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值