Recently I've been trying to move from CodeBlocks to Visual Studio Code, but the latter has been giving me problems especially when making projects with classes, in this case when trying to run it I get this window:
the preLaunchTask C/C++:g++.exe build active file terminated with exit code -1
If I click show errors it tells me no problems have been detected in the workspace
Then after clicking debug anyway this appears:
It's been a while since I've used VScode but I'm pretty sure that the launch program gets created when running the code of the program for the first time right?
Here are my launch.json and task.json:
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}/myfile.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true
},
{
"name": "(Windows) Attach",
"type": "cppvsdbg",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "build myfile",
"type": "shell",
"command": "g++",
"args": [
"-std=c++14",
"-g",
"-o",
"myfile.exe",
"myfile.cpp"
],
"group": "build"
},
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\msys64\\mingw64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
]
}
I got all the .json from this answer to a similar question: https://stackoverflow.com/a/50658089/19009898 I used to have different.json which I guess were the default ones but this change doesn't seem to make any trouble for other previous code without classes that I've made so I'm guessing it's ok.
Would appreciate the help.