3.7. Compiling Multiple Programs

In order to compile multiple programs within the same SConstruct file, simply call the Program method multiple times, once for each program you need to build:

       Program('bar', ['bar1.c', 'bar2.c'])

SCons would then build the programs as follows:

       % scons -Q
       cc -o bar1.o -c bar1.c
       cc -o bar2.o -c bar2.c
       cc -o bar bar1.o bar2.o
       cc -o foo.o -c foo.c
       cc -o foo foo.o

Notice that SCons does not necessarily build the programs in the same order in which you specify them in the SConstruct file. SCons does, however, recognize that the individual object files must be built before the resulting program can be built. We'll discuss this in greater detail in the "Dependencies" section, below.