I want to build a Rasterizer project with opencv.The below command work well in shell(some parameter is omitted, such as -static-libgcc
):
g++ *.cpp -g -o Rasterizer `pkg-config --libs opencv`
However, when I want to do the same thing with VSCode, it fails and throw an error:
g++: error: `pkg-config --libs opencv`: No such file or directory
The log tells me that the executed task in VSCode is(also omit some parameters)
g++ *.cpp -g -o Rasterizer '`pkg-config --libs opencv`'
I think the reason is the parameter
`pkg-config --libs opencv`
is surrounded by a pair of quotes '
and saw as literal. How can I solve this problem?
The whole error message can be seen here:
> Executing task: g++ /home/cs18/GAMES101/pa1/*.cpp -fdiagnostics-color=always -g -o /home/cs18/GAMES101/pa1/build/main -static-libgcc -fexec-charset=GBK '`pkg-config --libs opencv`' <
g++: error: `pkg-config --libs opencv`: No such file or directory
The terminal process "/bin/bash '-c', 'g++ /home/cs18/GAMES101/pa1/*.cpp -fdiagnostics-color=always -g -o /home/cs18/GAMES101/pa1/build/main -static-libgcc -fexec-charset=GBK '`pkg-config --libs opencv`''" failed to launch (exit code: 1).
My VSCode configuration file task.json
:
{
"tasks": [
{
"type": "shell",
"label": "C/C++: g++ build active file",
"command": "g++",
"args": [
"${fileDirname}/*.cpp",
"-fdiagnostics-color=always",
"-g",
"-o",
"${fileDirname}/build/${fileBasenameNoExtension}",
"-static-libgcc",
"-fexec-charset=GBK",
"`pkg-config --libs opencv`"
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "new"
},
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}