【问题标题】:VS Code "command": "make" differs from command line `make` in terminal windowVS Code“命令”:“make”与终端窗口中的命令行“make”不同
【发布时间】:2018-10-31 13:38:57
【问题描述】:

我前段时间安装了 VS Code for Linux,在工作区中打开了一个 C++ 项目,创建了tasks.json——一般我都是按照谷歌来做的。

当我在终端窗口中运行make 命令时,一切正常。但是当我从 VS Code 执行相同操作(Ctrl+Shift+B)时,我得到了一个错误。

处理我的Makefile 在命令libtool: link: c++ -fPIC -DPIC -shared -nostdlib /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/../../../x86_64-linux-gnu/crti.o .... 之后终止

有消息 c++: error: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/../../../x86_64-linux-gnu/crti.o: No such file or directory.

当然,路径是正确的(当我在终端窗口中使用命令行make 时很好)。

tasks.json 的内容很简单(与 microsoft.com 中的相同):

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
    {
        "label": "ClanLib",
        "type": "shell",
        "command": "make",
        // start the build without prompting for task selection, use "group": "build" otherwise
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "presentation": {
            "echo": true,
            "reveal": "always",
            "focus": false,
            "panel": "shared"
        },
        // arg passing example: in this case is executed make QUIET=0
        "args": ["QUIET=0"],
        // Use the standard less compilation problem matcher.
        "problemMatcher": {
            "owner": "cpp",
            "fileLocation": ["absolute"],
            "pattern": {
                "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                "file": 1,
                "line": 2,
                "column": 3,
                "severity": 4,
                "message": 5
            }
        }
    }
]
}

我无法发布Makefile,它包含从https://github.com/sphair/ClanLib 自动生成后的数千行代码...

请帮助设置 Visual Studio Code (Linux Mint)。

【问题讨论】:

  • 您好,欢迎来到 SO。请从您的 tasks.json 和 makefile 中提供更多内容。您提供的信息不足以让我们知道可能出了什么问题。
  • 你已经安装libc6-dev了吗?
  • Tezirg - 请参阅我更新的帖子。 Ayak973 - 显然没有安装,但从命令行一切正常。

标签: c++ linux visual-studio-code


【解决方案1】:

看起来您尝试使用目录中的 makefile 手动构建,并使用另一个目录中的 vscode。 如果是这种情况,您可以使用 cwd 选项告诉您的任务从特定目录运行 - doc

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format

    "version": "2.0.0",
    "tasks": [
        {
            "label": "ClanLib",
            "type": "shell",
            "command": "make",

            "options": {
                "cwd": "${workspaceRoot}/<DIR_WITH_MAKEFILE>"
            }
            ...
}]}

【讨论】:

  • 不幸的是它没有帮助,目录的一切都是正确的。 VS Code 显示在第一行&gt; Executing task in folder ClanLib: make QUIET=0 &lt;,这是正确的目录。
【解决方案2】:

我好像感觉到了什么。在 VSCode 内的终端窗口中,我看到了

 sh-4.4$ help
 GNU bash, версия 4.4.19(1)-release (x86_64-unknown-linux-gnu)

但在 OS 终端中:

art@artPC:~/git/ClanLib$ help
GNU bash, версия 4.4.19(1)-release (x86_64-pc-linux-gnu)

区别在于-unknown--pc-whoami 的结果在两个终端上是相同的。

最后在 VSCode 终端中:

sh-4.4$ ls
x86_64-unknown-linux-gnu

符号链接x86_64-unknown-linux-gnu 的名称在 OS 和 VSCode 之间是不同的。 VSCode 的错误?

【讨论】:

    【解决方案3】:

    解决方案在这里 https://github.com/Microsoft/vscode/issues/62532

    谢谢先生。 @jerch

    您安装了不同的构建集,请参阅“GNU Make 4.1”与“GNU Make 4.2.1”。出于某种原因 /bin/sh 默认为另一个。要解决这个问题,您必须查阅发行版的帮助(在 Ubuntu 中,您可以使用 update-alternatives 命令切换构建集)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-10
      • 2013-02-06
      • 2015-12-19
      • 1970-01-01
      • 1970-01-01
      • 2015-04-04
      • 1970-01-01
      相关资源
      最近更新 更多