Failed to launch external program in VSCode with pkg-config

╄→гoц情女王★ 提交于 2020-08-07 07:39:30

问题


I have created a simple main.cpp. I have also created a tasks.json under .vscode folder which is as follow.

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "0.1.0",
  "command": "g++ $(pkg-config --cflags --libs opencv)",
  "isShellCommand": true,
  "args": ["main.cpp"],
  "showOutput": "always"
}

g++ $(pkg-config --cflags --libs opencv) main.cpp is running properly in terminal. However, it's not working in the task runner in vscode. The error message is

Failed to launch external program g++ $(pkg-config --cflags --libs opencv)

Any suggestion for that ?


回答1:


I got my program to work with the following tasks.json:

{
"tasks": [
    {
        "type": "shell",
        "label": "g++ build active file",
        "command": "/usr/bin/g++",
        "args": [
            "-g",
            "${file}",
            "-o",
            "${fileDirname}/${fileBasenameNoExtension}",
            "`pkg-config", "--cflags", "--libs", "opencv`"
        ],
        "options": {
            "cwd": "/usr/bin"
        }
    }
],
"version": "2.0.0" }

You have to separate each command with "" like so "pkg-config", "--cflags", "--libs", "opencv". Hope that helps.



来源:https://stackoverflow.com/questions/38565074/failed-to-launch-external-program-in-vscode-with-pkg-config

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!