Node:Dynamic Linking, Next:, Previous:Static Linking, Up:Multiple Sources



Dynamic Linking

The main program and subprograms can be compiled separately.

The main program is compiled as usual:

     $ cobc -o main main.cob
     

Subprograms are compiled with the option -m:

     $ cobc -m subr.cob
     
This creates a module file subr.so 1.

Before running the main program, install the module files in your library directory:

     $ cp subr.so /your/cobol/lib
     

Now, set the environment variable COB_LIBRARY_PATH to your library directory, and run the main program:

     $ export COB_LIBRARY_PATH=/your/cobol/lib
     $ ./main
     

Footnotes

  1. The extension varies depending on your host.