Reputation: 89
I run VScode on ubuntu16, and test the helloworld.cpp. At first, I walked through all, then I tried to edit the tasks.json. I got the error. Ok, I cancel all the the change with rollback, it shows error aagin. I remove the helloworld folder and try again the helloworld. After Terminal > Configure Default Build Task and build, the error shows again. What's the wrong? It is got from vscode.
The error message:
Executing task: /usr/bin/g++ -g /home/liwenz/helloworld/.vscode/tasks.json -o /home/liwenz/helloworld/.vscode/tasks <
/usr/bin/ld:/home/liwenz/helloworld/.vscode/tasks.json: file format not recognized; treating as linker script /usr/bin/ld:/home/liwenz/helloworld/.vscode/tasks.json:1: syntax error collect2: error: ld returned 1 exit status The terminal process terminated with exit code: 1
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
the helloworld link is https://code.visualstudio.com/docs/cpp/config-linux
Upvotes: 4
Views: 9397
Reputation: 141
You have to switch from the tasks.json file to the actual code you want to compile or debug.
Upvotes: 10
Reputation: 89
As I build, I open tasks.json. So ${File}=tasks.json I should open helloworld.cpp, then ${File}=helloword.cpp, and build ok.
Upvotes: 3