C Functions, Integration

The steps necessary to integrate a user C program with the D3 run-time library are:

The following describes the necessary procedures to create the cdemo example application shipped with the D3 package.

To create the example application:

  1. In UNIX, copy Makefile and cdemo.c to the current directory.

  2. Go to your UNIX user’s home directory and copy Makefile and cdemo.c from
    /usr/lib/pick.

  3. Log in to D3 and type addbi with no arguments.

  4. The addbi command builds a dummy branch table for use by the BASIC-C interface. This branch table is not directly used by the C to D3 interface, but is required to properly link the D3 run-time library. This step creates two modules called px.user.o and libgmu.a. These modules need only to be created once.

  5. Edit the C program source code and Makefile.

  6. For the cdemo program, the source code is already complete. If this were a new program, the user would change the desired source file or files, and modify Makefile to integrate those files into the final link.

  7. Link the application using make.

  8. In UNIX, type make cdemo. This compiles the cdemo.c source into an object and links this with the D3 run-time library to create a UNIX application.

  9. Run the application.

  10. When the make completes, an application called cdemo will exist on the current directory. This application is similar to the UNIX cat program, except that cdemo outputs the raw contents of a D3 file and item. For instance, to view the color program in dm,bp, type:

    ./cdemo bp color

    Debugging can be done with the usual UNIX debuggers such as sdb or dbx.

See Also

Introduction