Appendix F.1 Creating a shared library

After you finish coding the UOC, you must create a shared library. Specify the created shared library and the functions to be called in the control statements for pdload or pdrorg.

Organization of this subsection
(1) For HP-UX
(2) For Solaris
(3) For Linux
(4) For AIX 5L

(1) For HP-UX

This example creates a shared library named libuoc.sl from the three source files sample1.c, sample2.c, and sample3.c:

  1. Compile the files with the +z option specified.

    $ /usr/bin/cc -c -I $PDDIR/include +z sample1.c sample2.c sample3.c
    sample1.c:
    sample2.c:
    sample3.c:

  2. Link the created files with extension .o.

    $ /bin/ld -b -o libuoc.sl sample1.o sample2.o sample3.o

(a) For HiRDB in the 64-bit mode

To execute the UOC on a HiRDB in the 64-bit mode, you must compile it in the 64-bit mode. In this case, specify +DD64 as the compile option. For the HP-UX (IPF) version, specify .so as the extension for shared libraries.

(b) POSIX library version of HiRDB

To execute the UOC on a POSIX library version of HiRDB, multi-threads must be supported. Note that multi-threads cannot be used within the UOC.

If you are using the POSIX library version of HiRDB, also note the following:

(2) For Solaris

This example creates a shared library named libuoc.so from the three source files sample1.c, sample2.c, and sample3.c:

  1. Compile the files.

    $ /usr/ucb/cc -c -I$PDDIR/include sample1.c sample2.c sample3.c
    sample1.c:
    sample2.c:
    sample3.c:

  2. Link the created files with extension .o.

    $ /usr/css/bin/ld -G -o libuoc.so sample1.o sample2.o sample3.o

(a) HiRDB in the 64-bit mode

To execute the UOC on a HiRDB in the 64-bit mode, you must compile it in the 64-bit mode. In this case, specify -xarch=v9 as the compile option.

(3) For Linux

This example creates a shared library named libuoc.so from the three source files sample1.c, sample2.c, and sample3.c:

  1. Compile the files.

    $ /usr/bin/cc -c -I$PDDIR/include sample1.c sample2.c sample3.c
    sample1.c:
    sample2.c:
    sample3.c:

  2. Link the created files with extension .o.

    $ /usr/bin/cc -shared -o libuoc.so sample1.o sample2.o sample3.o

(4) For AIX 5L

This example creates a shared library named libuoc.so from the three source files sample1.c, sample2.c, and sample3.c:

  1. Compile the files.

    $ /usr/vac/bin/xlc -c -I$PDDIR/include sample1.c sample2.c sample3.c
    sample1.c:
    sample2.c:
    sample3.c:

  2. Link the created files with extension .o.

    $ /usr/vac/bin/xlc -G -o libuoc.so sample1.o sample2.o sample3.o

(a) HiRDB in the 64-bit mode

To execute the UOC on a HiRDB in the 64-bit mode, you must compile it in the 64-bit mode. In this case, specify -q64 as the compile option.

(b) POSIX library version of HiRDB

To execute the UOC on a POSIX library version of HiRDB, multi-threads must be supported. Note that multi-threads cannot be used within the UOC.

If you are using a POSIX library version of HiRDB, also note the following:

During compilation, use the xlc_r command.

For details about supporting multi-threads, see the applicable OS documentation.