Building C libraries for Isis

Once you have written and polished a set of C functions that perform certain kinds of related tasks, it is often desirable to create a C library that contains those functions. Any programs that wish to use those functions (such as Isis interpreters) would then simply link to that library instead of compiling all of the same source code separately. This document explains how to form such a library from your C functions.

  1. If you followed the instructions for binding C functions to Isis, your C code should already be in files of its own (separate from the file containing the main() function). There should be one or more functions that are responsible for making bindings in the Isis interpreter when they are called. There should also be a single header file that will contain all the declarations of these binder functions and any others that should be "visible" to programs that will use your library. You can have other "internal" header files if you want, but only one special header file will be installed.

  2. Create a new folder where your library's source code will reside. Copy the C source code and header files to this folder. There should not be a main() function anywhere in these files.

  3. Copy the Makefile template for an Isis library to this folder and make sure it is named Makefile with a capital M.

  4. Edit the Makefile. You will have to enter a name for your library on the LIBNAME line and the names of your all your source (.c) files on the SRCS line. Enter the name of the header file that will be installed on the HEADERS line. You must list at least one header file on this line.

    Follow these naming rules for your library:

  5. To actually make the library, simply type:

  6. To install the library and its header file in the master Isis bin and include directories on your machine, type:
    make install
    Anyone compiling an Isis application on your machine should now be able to use the library by simply including the header file in its source, like this:
    #include <isis_cool.h>
    and linking with your library on the LIBS line of its Makefile, like this:

  7. If you ever want to remake the entire library from scratch, erasing any old intermediate files from previous compilations, type:
    make clean install