By default, the linker will only look in
certain system-defined directories for libraries.
SCons knows how to look for libraries
in directories that you specify with the
$LIBPATH construction variable.
$LIBPATH consists of a list of
directory names, like so:
Program('prog.c', LIBS = 'm', LIBPATH = ['/usr/lib', '/usr/local/lib'])
Using a Python list is preferred because it's portable across systems. Alternatively, you could put all of the directory names in a single string, separated by the system-specific path separator character: a colon on POSIX systems:
LIBPATH = '/usr/lib:/usr/local/lib'
or a semi-colon on Windows systems:
LIBPATH = 'C:\\lib;D:\\lib'
(Note that Python requires that the backslash separators in a Windows path name be escaped within strings.)
When the linker is executed, SCons will create appropriate flags so that the linker will look for libraries in the same directories as SCons. So on a POSIX or Linux system, a build of the above example would look like:
scons -Qcc -o prog.o -c prog.c cc -o prog prog.o -L/usr/lib -L/usr/local/lib -lm
On a Windows system, a build of the above example would look like:
scons -Qcl /Foprog.obj /c prog.c /nologo link /nologo /OUT:prog.exe /LIBPATH:\usr\lib /LIBPATH:\usr\local\lib m.lib prog.obj embedManifestExeCheck(target, source, env)
Note again that SCons has taken care of the system-specific details of creating the right command-line options.