First, create a file called
SConstruct (note that SCons will look for a file with this exact name by default). For now, the file should be in a directory right along your
hello.cpp. Write in the new file the line
Now, from the terminal, run
scons. You should see something like
$ scons scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... g++ -o hello.o -c hello.cpp g++ -o hello hello.o scons: done building targets.
(although the details will vary depending on your operating system and installed compiler).
Glob classes will help you further configure what to build. E.g., the
env=Environment(CPPPATH='/usr/include/boost/', CPPDEFINES=, LIBS=, SCONS_CXX_STANDARD="c++11" ) env.Program('hello', Glob('src/*.cpp'))
builds the executable
hello, using all
cpp files in
/usr/include/boost and it specifies the C++11 standard.