b68
Directory Search for Link Libraries
Contents|Index|Previous|Next
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 lib name.a, not like -lname.)
When a dependencys 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). Use the following example, for instance.
foo : foo.c -lcurses
cc $ -o $@
This would cause the command, cc foo.c /usr/lib/libcurses.a -o foo, to execute when foo is older than foo.c or /usr/lib/libcurses.a.
0