I'm trying to compile a very simple code. I put in tasks.json configuration copied from here.
{
"version": "2.0.0",
"tasks": [
{
"label": "build & debug file",
"type": "shell",
"command": "g++",
"args": [
"-g",
"-o",
"${fileBasenameNoExtension}",
"${file}"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "build & run file",
"type": "shell",
"command": "g++",
"args": [
"-o",
"${fileBasenameNoExtension}",
"${file}"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
But when I build (ctrl+shift+b) I get errors:
usr/bin/ld:/home/username/LinuxProjects/FirstCppProject/.vscode/tasks.json: file format not recognized; treating as linker script /usr/bin/ld:/home/username/LinuxProjects/FirstCppProject/.vscode/tasks.json:1: syntax error collect2: error: ld returned 1 exit status The terminal process terminated with exit code: 1
I don't understand what's wrong with the json.
This is compiling the currently active file, so you have to ensure you have the intended source file is active (i.e. open and in view). If you run this command when the task.json file is active, it will attempt to compile the task.json file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With