2.2. Building Object Files

The Program builder is only one of many builders (also called a builder method) that SCons provides to build different types of files. Another is the Object builder method, which tells SCons to build an object file from the specified source file:

Object('hello.c')
      

Now when you run the scons command to build the program, it will build just the hello.o object file on a POSIX system:

% scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cc -o hello.o -c hello.c
scons: done building targets.

And just the hello.obj object file on a Windows system (with the Microsoft Visual C++ compiler):

C:\>scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fohello.obj /c hello.c /nologo
scons: done building targets.

(Note that this guide will not continue to provide duplicate side-by-side POSIX and Windows output for all of the examples. Just keep in mind that, unless otherwise specified, any of the examples should work equally well on both types of systems.)