The method of creating a shareable library varies by the operating system. The following examples illustrate the commands to be used on an HP-UX system, a Hewlett-Packard UNIX system, and 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 HP-UX:
Example:
$ cc -Aa -c +z -I$gtm_dist increment.c decrement.c $ ld -b -o libcrement.sl increment.o decrement.o -lc
![]() | Note |
---|---|
Refer to the "Programming on HP-UX" manual for information on shareable libraries under HP-UX. |
On Hewlett-Packard Tru64 UNIX:
Example:
$ cc -c -xtaso -xtaso_short -I$gtm_dist increment.c decrement.c $ ld -shared -taso -o libcrement.sl increment.o derement.o -lc
![]() | Note |
---|---|
Refer to the "Tru64 Programmer's Guide" for information on shareable libraries under HP UNIX. |
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 |
---|---|
Refer to the AIX V4.2 documentation of the ld(1) AIX command for information on shareable libraries under AIX V4.2. |
On Sun Solaris (Solaris 2.6 & higher):
Example:
%/opt/SUNWspro/bin/cc -c -KPIC -I$gtm_dist increment.c decrement.c % ld -o libcrement.so -G increment.o decrement -lc
On Linux x86:
Example:
% gcc -c -fPIC -I$gtm_dist increment.c decrement.c % gcc -o libcrement.so -shared increment.o decrement.o