A Mercury implementation should allow you to link with object files or libraries that were produced by compiling C code. The exact mechanism for linking with C object files is implementation-dependent. The following text describes how it is done for the University of Melbourne Mercury implementation.
To link an existing object file into your Mercury code, use the command line option ‘--link-object’. For example, the following will link the object file ‘my_function.o’ from the current directory when compiling the program ‘prog’:
mmc --link-object my_functions.o prog
The command line option ‘--library’ (or ‘-l’ for short) can be used to link an existing library into your Mercury code. For example, the following will link the library file ‘libfancy_library.a’, or perhaps the shared version ‘libfancy_library.so’, from the directory ‘/usr/local/contrib/lib’, when compiling the program ‘prog’:
mmc -R/usr/local/contrib/lib -L/usr/local/contrib/lib --lfancy_library prog
As illustrated by the example, the command line options ‘-R’, ‘-L’ and ‘-l’, have the same meaning as they do with the Unix linker.
For more information, see the “Libraries” chapter of the Mercury User's Guide.