无法在 Mac 上使用通配符 (*) 编译多个 C++ 文件,在 Windows 上工作正常

Cannot compile multiple C++ files using wildcard (*) on Mac, works fine on Windows

我正在尝试在 Sublime Text 2 sublime-build file 中使用 g++ 一次编译多个 C++ 文件。使用通配符在我的 Windows 桌面上工作正常,但在我的 Mac 书上不起作用,我怎样才能让通配符在我的 Mac 上工作?

sublime-build 文件:

{
"cmd": ["g++", "-std=c++11", "-I", "/Users/Dan2/YorickTheSavant/include",

"/Users/Dan2/YorickTheSavant/src/*",

"-o", "/Users/Dan2/YorickTheSavant/Yorick the Savant",
"-F", "/Users/Dan2/Library/Frameworks",
"-framework", "sfml-system",
"-framework", "sfml-window",
"-framework", "sfml-graphics"],

"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "/Users/Dan2/YorickTheSavant/",
"selector": "source.c, source.c++",

"variants":
[
    {
        "name": "Run",
        "cmd": ["/Users/Dan2/YorickTheSavant/Yorick the Savant"]
    }
]
}

输出:

clang: error: no such file or directory: '/Users/Dan2/YorickTheSavant/src/*'

问题是这样的:

Using G++ to compile multiple *.cpp and *.h files in Sublime 2

The reason why using *.cpp in Sublime Text fails is, gcc does not do wild card expansion. When you run gcc from command line with wild cards, the shell expands them and gives gcc a list of file names. So you need to find out how to do equivalent (of getting file names by wildcards or other similar method) in Sublime Text.

OP 能够使用此解决方法:

{
"cmd" : ["g++ *.cpp -o executablename"],
"shell":true
}