Hello world
SConstruct file
Create a pain text file called SConstruct
containing the following:
Program(source = 'main.c')
e.g.
.
├── SConstruct
└── main.c
Build
Enter the command scons
at the CLI:
$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gcc -o main.o -c main.c
gcc -o main main.o
scons: done building targets.
This creates an executable file main
Run
$ ./main
Hello from scons
Cleanup
To remove all intermediate files (e.g. .o
files), simple invoke scons with the cleanup -c
flag:
$ scons -c
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Cleaning targets ...
Removed main.o
Removed main
scons: done cleaning targets.