无法使用 pkg-config 在 VSCode 中启动外部程序 [英] Failed to launch external program in VSCode with pkg-config

查看:78
本文介绍了无法使用 pkg-config 在 VSCode 中启动外部程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个简单的 main.cpp.我还在 .vscode 文件夹下创建了一个 tasks.json,如下所示.

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 在终端中正常运行.但是,它在 vscode 中的任务运行器中不起作用.错误信息是

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

无法启动外部程序 g++ $(pkg-config --cflags --libs opencv)

对此有什么建议吗?

推荐答案

我的程序可以使用以下 tasks.json:

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" }

你必须用"分隔每个命令,就像pkg-config"、--cflags"、--libs"、opencv".希望有所帮助.

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

这篇关于无法使用 pkg-config 在 VSCode 中启动外部程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆