Next: , Previous: Building libretto, Up: Top


4 Using Libretto with your own programs

The distribution installs several header files as well as the library binary itself; the header files are put in a directory named libretto. By default, the header directory and library binary are installed in the include and lib directories respectively of the /usr/local tree, though this may be changed when configuring Libretto. The process of compiling a source file with the Libretto declarations and linking the resulting object file against Libretto may then be as simple as:

     $ cc -c foo.c
     $ cc -o foo foo.o -libretto

On other systems, however, the compiler and linker may not look in /usr/local by default; those commands should then be:

     $ cc -I/usr/local/include -c foo.c
     $ cc -L/usr/local/lib -o foo foo.o -libretto

Of course, the header files and library may be installed to any directory tree in the filesystem, not just /usr/local.

A few notes about the portability of the header files are in order here. Any compiler should be able to use the header files, as long as the public header files stdarg.h, stdio.h, unistd.h and sys/types.h are available. stdarg.h and stdio.h should be ANSI/ISO C89 compliant, while unistd.h and sys/types.h should be (broadly) POSIX compliant. If these files are available, but none of them defines the types ‘size_t’ and ‘ssize_t’, then source files including the libretto header files must themselves ensure that those types are available. This will not apply to POSIX or POSIX-like systems.

Any program using Libretto should include libretto/libretto.h; this is the global header file for Libretto. Other header files are also needed; each chapter of this manual mentions the headers required by the features it describes.