VS代码“命令”:“ make”与终端窗口中的命令行“ make”不同

时间:2018-10-31 13:38:57

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

前段时间,我为Linux安装了VS Code,在工作区中打开了一个C ++项目,创建了tasks.json-一般来说,我根据Google所做的一切。

当我在终端窗口中运行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代码(Linux Mint)。

3 个答案:

答案 0 :(得分:0)

似乎您尝试使用目录中的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>"
            }
            ...
}]}

答案 1 :(得分:0)

似乎我有种感觉。在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)

区别是-未知- -pc-whoami的结果在两个终端上都相同。

最后在VSCode终端中:

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

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

答案 2 :(得分:0)

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

谢谢先生。 @jerch

  

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