本文介绍了使用G ++在Sublime 2中编译多个* .cpp和* .h文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

在MAC上,我可以使用

从命令行成功编译c ++程序。

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

但是它在Sublime 2中失败 - 我使用

创建了一个构建系统>

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

有了这些结果

  i686-apple-darwin11-llvm-g ++  -  4.2:* .cpp:没有这样的文件或目录
i686-apple-darwin11-llvm- g ++ - 4.2:* .h:没有这样的文件或目录
i686-apple-darwin11-llvm-g ++ - 4.2:没有输入文件
[以0.0s退出代码1完成]
但是,如果我在项目中创建具有特定文件名的构建系统,它会工作:


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

如何在Sublime 2中创建一个使用命令行模式编译多个文件的构建系统,就像我可以在命令行中一样。

解决方案

感谢海德。



使用基于您的建议的构建系统后,此工作原理:

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


On a MAC I can successfully compile a c++ program from the command line using

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

However it fails from within Sublime 2 - I created a build system for this using

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

With these results

 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]

However, if I create the build system with specific filenames in the project it works:

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

How can I create a build system in Sublime 2 that uses command line patterns to compile multiple files like I can on the command line?

解决方案

Thanks hyde.

After playing with the build system based on your suggestion, this works:

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

这篇关于使用G ++在Sublime 2中编译多个* .cpp和* .h文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 09:23