Something wrong when using pkg-config to compile program in Visual Studio Code

30 views Asked by At

My tasks.json is like this:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++ 生成活动文件",
            "command": "/usr/bin/g++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}",
                "`pkg-config --libs --cflags opencv4`"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "编译器: /usr/bin/g++"
        }
    ]
}

I want to use pkg-config to find opencv4 includes and libs,and compile my program,but the result VSCode giving is like this:

/usr/bin/g++ -fdiagnostics-color=always -g /home/xlg/Documents/any_test/test.cpp -o /home/xlg/Documents/any_test/test '`pkg-config --libs --cflags opencv`'
g++: error: `pkg-config --libs --cflags opencv`: no such file or directory

There are unwanted ' ' surrounded,How to modify code to get the following command?

/usr/bin/g++ -fdiagnostics-color=always -g /home/xlg/Documents/any_test/test.cpp -o /home/xlg/Documents/any_test/test `pkg-config --libs --cflags opencv`
0

There are 0 answers