Once a library is installed, using it is easy. Suppose the user wishes to use the library ‘mypackage’ (installed in the tree rooted at ‘/some/directory/mypackage’) and the library ‘myotherlib’ (installed in the tree rooted at ‘/some/directory/myotherlib’). The user need only set the following Mmake variables:
EXTRA_LIB_DIRS = /some/directory/mypackage/lib/mercury \ /some/directory/myotherlib/lib/mercury EXTRA_LIBRARIES = mypackage myotherlib
When using ‘--intermodule-optimization’ with a library which uses the C interface, it may be necessary to add ‘-I’ options to ‘MGNUCFLAGS’ so that the C compiler can find any header files used by the library's C code.
Mmake will ensure that the appropriate directories are searched for the relevant interface files, module initialisation files, compiled libraries, etc.
Beware that the directory name that you must use in ‘EXTRA_LIB_DIRS’ or as the argument of the ‘--mld’ option is not quite the same as the name that was specified in the ‘INSTALL_PREFIX’ when the library was installed — the name needs to have ‘/lib/mercury’ appended.
One can specify extra libraries to be used on a program-by-program basis. For instance, if the program ‘foo’ also uses the library ‘mylib4foo’, but the other programs governed by the Mmakefile don't, then one can declare:
EXTRA_LIBRARIES-foo = mylib4foo