|Command||cfunc.integration Definition/C Functions
Applicable release versions: AP 6.1
|Category||C Functions (120)|
|Description||the steps necessary to integrate a user C program with the Pick run-time library:
- Build a branch table (which may be empty) for any functions which will be called by BASIC subroutines calling percent function calls.
- Edit and compile the user C program(s).
- Link the application with the Pick run-time library
The following describes the necessary procedures to create the "cdemo" example application shipped with the Pick package.
The steps required for creating this application are:
- Step 1: In Unix, copy "Makefile" and "cdemo.c" to the current directory.
Go to your Unix user's home directory and copy "Makefile" and "cdemo.c" from "/usr/lib/pick".
- Step 2: Enter Pick, and type "addbi" with no arguments.
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-Pick interface, but is required to properly link the Pick run-time library. This step creates two modules called "px.user.o" and "libgmu.a". These modules need only to be created once.
- Step 3: Edit the C program source code and Makefile
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.
- Step 4: Link the application using "make".
In Unix, type "make cdemo". This will compile the "cdemo.c" source into an object and link this with the Pick run-time library to create a Unix application.
- Step 5: Run the application
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 Pick file and item. For instance, to view the "color" program in "dm,bp," type the following:
./cdemo bp color
Debugging can be done with the usual Unix debuggers like sdb or dbx.