【问题标题】:How to configure VSCode task to compile multiple files on Linux?如何配置 VSCode 任务以在 Linux 上编译多个文件?
【发布时间】:2020-07-14 03:44:11
【问题描述】:

我有一个要在 VSCode 中编译的项目,该项目由多个源文件组成,并且想在我的任务中添加一个参数,告诉 g++ 链接所有扩展名为 .cpp 的文件。以下方法不起作用:

"args": [
    "${workspaceFolder}/*.cpp*",
    ...

g++: error: /home/kirusfg/Study/Programming/CSCI 152/Assignments/Assignment 4/*.cpp*: No such file or directory,

虽然

g++ '/home/kirusfg/Study/Programming/CSCI 152/Assignments/Assignment 4/*.cpp*' -o main-optimized.out -g -O5 -flto -Wreturn-type -pedantic -pedantic-errors -Wundef -std=c++17

如果通过终端输入可以完美运行。

【问题讨论】:

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


    【解决方案1】:

    在我看来,您的“workspaceFolder”路径中的空间存在问题,“args”字段不能很好地处理空间。

    看来您最好的选择是将 arg 添加到“命令”字段。

    即:

    ... 
    "command": "g++ ${workspaceFolder}/*.cpp*",
    "args":[],
    ...
    

    我希望它能解决你的问题。

    参考: 查看来自 VScode GitHub 的已关闭问题:How to pass arguments with space to tasks correctly

    【讨论】:

    • 终端shell路径“/home/kirusfg/Study/Programming/CSCI 152/Assignments/Assignment 4/*.cpp*”不存在
    • 你能把整个任务贴出来吗?
    猜你喜欢
    • 2016-10-19
    • 2014-03-27
    • 2020-09-21
    • 1970-01-01
    • 1970-01-01
    • 2019-11-18
    • 1970-01-01
    • 1970-01-01
    • 2022-07-02
    相关资源
    最近更新 更多