gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 01:46:55 26 4
gpt4 key购买 nike

我正在尝试在 Sublime Text 2 中使用 g++ 一次编译多个 C++ 文件 sublime-build file .使用通配符在我的 Windows 桌面上工作正常,但在我的 Macbook 上不起作用,我如何让通配符在我的 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:错误:没有这样的文件或目录:'/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
}

关于c++ - 无法在 Mac 上使用通配符 (*) 编译多个 C++ 文件,在 Windows 上工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32427663/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com