gpt4 book ai didi

c++ - 在 Sublime 2 中使用 G++ 编译多个 *.cpp 和 *.h 文件

转载 作者:搜寻专家 更新时间:2023-10-30 23:58:05 25 4
gpt4 key购买 nike

在 MAC 上,我可以使用命令行从命令行成功编译 c++ 程序

  g++ *.cpp *.h -o executablename

但是它在 Sublime 2 中失败了——我为此使用创建了一个构建系统

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

有了这些结果

 i686-apple-darwin11-llvm-g++-4.2: *.cpp: No such file or directory
i686-apple-darwin11-llvm-g++-4.2: *.h: No such file or directory
i686-apple-darwin11-llvm-g++-4.2: no input files
[Finished in 0.0s with exit code 1]

但是,如果我在项目中创建具有特定文件名的构建系统,它会起作用:

{
"cmd" : ["g++", "Test.cpp", "TestCode.cpp", "TestCode.h", "TestCode2.cpp", "TestCode2.h", "-o", "executablename"]
}

我如何在 Sublime 2 中创建一个构建系统,它使用命令行模式来编译多个文件,就像我在命令行上一样?

最佳答案

谢谢海德。

根据您的建议使用构建系统后,这有效:

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

关于c++ - 在 Sublime 2 中使用 G++ 编译多个 *.cpp 和 *.h 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21956428/

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