In our case, we encountered an issue related to the auto-generated .vscode folder when debugging for the first time. To resolve this problem, we followed these steps:
The deletion of the executable file, and the location of the gcc.exe file. By following these steps, we were able to resolve the debugging issues in VS Code and successfully build our code.
If you are encountering the error message "the prelaunchtask 'c/c++: clang build active file' terminated with exit code -1" in your C/C++ development environment, it is likely related to issues with the prelaunch task configuration or the build settings. Here's a detailed solution to solve this problem:
tasks.json
in Visual Studio Code. Make sure the task is correctly defined, and there are no errors or typos in the configuration.Here's an example of a possible tasks.json
configuration for building a C++ file with Clang:
{
"version": "2.0.0",
"tasks": [
{
"label": "clang-build-active-file",
"type": "shell",
"command": "clang++",
"args": [
"-std=c++11",
"-o",
"${fileBasenameNoExtension}.out",
"${file}"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
After applying these steps, try building your C/C++ project again. If the issue still persists, carefully review any error messages in the console or build output for additional information about the root cause of the problem.
To fix this issue, I made the following configuration changes in my launch.json
file:
"-arch", "x86_64",
"targetarchitecture": "x86_64",
"osx": {
"prelaunchtask": "c/c++: g++ build active file",
"mimode": "lldb"
}
These changes specify the architecture as x86_64
and set the appropriate prelaunch task and debugging mode for macOS, resolving the issue.
I encountered the same problem, and I found that Visual Studio Code (VSCode) does not currently support a debugger for arm64 binaries.
However, I discovered a workaround by using another extension. You can install codelldb and set "type": "lldb"
in your launch.json
file as shown below:
{
"version": "0.2.0",
"configurations": [
{
"name": "clang++ - build and debug active file",
"type": "lldb",
"request": "launch",
"program": "${filedirname}/${filebasenamenoextension}",
"args": [],
"cwd": "${workspacefolder}",
"prelaunchtask": "clang++ build active file"
}
]
}
This configuration allows you to use the codelldb extension for debugging, resolving the issue with debugging arm64 binaries in VSCode.
If none of the above solutions work, we can try the following steps:
Deleting the contents in the .vscode folder and restarting VSCode can help reset any potential configuration issues. Additionally, replacing "${file}" with "${workspaceFolder}\*.cpp" in the tasks.json file ensures that the correct files are targeted for compilation. By following these steps, we can resolve the issues with executing C/C++ programs in VSCode.