vscodeC语言环境配置出现问题

Visual Studio Code
X
launch: program 'G:\cod\1.exe' does not exist

打开"launchjson"取消

  • 文章:vscode配置c语言环境以及launch:program“*****.exe” does not exist问题(保姆级检查) 中也许有你想要的答案,请看下吧
  • 除此之外, 这篇博客: VS Code 问题:launch:program‘...\.vscode\launch.exe‘ dose not exist中的 解决过程 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • 根据问题描述,查找 “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 !” 真难说出口。

task.json配置编译。
launch.json配置调试运行编译好的程序
你这个应该是没有编译成功