Prev: Implicit/Search Up: Directory Search

Directory Search for Link Libraries

   Directory search applies in a special way to libraries used with the
linker.  This special feature comes into play when you write a
dependency whose name is of the form `-lNAME'.  (You can tell something
strange is going on here because the dependency is normally the name of
a file, and the *file name* of the library looks like `libNAME.a', not
like `-lNAME'.)

   When a dependency's name has the form `-lNAME', `make' handles it
specially by searching for the file `libNAME.a' in the current
directory, in directories specified by matching `vpath' search paths
and the `VPATH' search path, and then in the directories `/lib',
`/usr/lib', and `PREFIX/lib' (normally `/usr/local/lib').

   For example,

     foo : foo.c -lcurses
             cc $^ -o $@

would cause the command `cc foo.c /usr/lib/libcurses.a -o foo' to be
executed when `foo' is older than `foo.c' or than

automatically generated by info2www