When setting up an embedded C development environment using Visual Studio Code (VSC), if you encounter the error “Can’t compile code ‘launch: program does not exist'”, the solution is as follows:
1. Place the following three files, launch.json, settings.json, tasks.json, in the project directory\.vscode.
launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"console": "externalTerminal"
},
{
"name": "(Windows) Attach",
"type": "cppvsdbg",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
settings.json:
{
"files.associations": {
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"exception": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"streambuf": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp"
}
}
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "build myfile",
"type": "shell",
"command": "g++",
"args": [
"-std=c++14",
"-g",
"-o",
"${fileBasenameNoExtension}.exe",
"${fileBasename}"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
2. compile the program:
gcc hello.c -o hello.exe
3. In VSC, File -> Open Folder, then click [Run] and select (Windows)Launch to proceed.
reference:
Can’t compile code “launch: program <program_path> does not exist “