Creating a Shareable Library

The method of creating a shareable library varies by the operating system. The following examples illustrate the commands on an IBM pSeries (formerly RS/6000) AIX system.

Example:

$ cat increment.c
int increment(int count, float *invar, float *outvar)
{
    *outvar=*invar+1.0;
    return 0;
}
$ cat decrement.c
int decrement(int count, float *invar, float *outvar)
{
     *outvar=*invar-1.0;
     return 0;
}        

On IBM pSeries AIX:

Example:

$ cc -c -I$gtm_dist increment.c decrement.c
$ ld -o libcrement.so increment.o decrement.o -G -bexpall -bnoentry -bh:4 -lc
[Note] Note

Refer to the AIX V4.2 documentation of the ld(1) AIX command for information on shareable libraries under AIX V4.2.

On Linux x86:

Example:

% gcc -c -fPIC -I$gtm_dist increment.c decrement.c
% gcc -o libcrement.so -shared increment.o decrement.o