3.7. Compiling Multiple Programs
Prev | Chapter 3. Less Simple Things to Do With Builds | Next

## 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('foo.c')
    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. (This will be covered in greater detail in Chapter 6, Dependencies, below.)

Prev | Up | Next
3.6. Keyword Arguments | Home | 3.8. Sharing Source Files Between Multiple Programs