简体   繁体   English

无法使用 pkg-config 在 VSCode 中启动外部程序

[英]Failed to launch external program in VSCode with pkg-config

I have created a simple main.cpp.我创建了一个简单的 main.cpp。 I have also created a tasks.json under .vscode folder which is as follow.我还在 .vscode 文件夹下创建了一个 tasks.json,如下所示。

{
  // 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. g++ $(pkg-config --cflags --libs opencv) main.cpp在终端中正常运行。 However, it's not working in the task runner in vscode.但是,它在 vscode 中的任务运行器中不起作用。 The error message is错误信息是

Failed to launch external program g++ $(pkg-config --cflags --libs opencv)无法启动外部程序 g++ $(pkg-config --cflags --libs opencv)

Any suggestion for that ?有什么建议吗?

I got my program to work with the following tasks.json:我让我的程序使用以下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 ".你必须用“”分隔每个命令,就像“ pkg-config", "--cflags", "--libs", "opencv ”。 Hope that helps.希望有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM