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?
You should perhaps use something like this:
Or possibly just
make
instead ofgmake
. But if you havegcc
, GNU make should be in same directory. Below example Makefile is tested with GNU Make, it might not work without small modifications elsewhere.So here's a very primitive Makefile for you. Important! It should be named
Makefile
so GNU Make will find it without arguments, and in it you must use actual tab char for indentation (before g++ and rm command below).But even using hand-written Makefile can be considered primitive these days. You should perhaps install and learn to use CMake.
Thanks hyde.
After playing with the build system based on your suggestion, this works: