24.4. Checking for the Availability of a Library

Check for the availability of a library using the CheckLib method. You only specify the basename of the library, you don't need to add a lib prefix or a .a or .lib suffix:


    env = Environment()
    conf = Configure(env)
    if not conf.CheckLib('m'):
        print 'Did not find libm.a or m.lib, exiting!'
        Exit(1)
    env = conf.Finish()
    

Because the ability to use a library successfully often depends on having access to a header file that describes the library's interface, you can check for a library and a header file at the same time by using the CheckLibWithHeader method:


    env = Environment()
    conf = Configure(env)
    if not conf.CheckLibWithHeader('m', 'math.h', 'c'):
        print 'Did not find libm.a or m.lib, exiting!'
        Exit(1)
    env = conf.Finish()
    

This is essentially shorthand for separate calls to the CheckHeader and CheckLib functions.