Oracle7 Administrator's Reference for UNIX

Contents Index Home Previous Next

Shared Libraries and Shared Objects Support

UNIX supports shared libraries and archive libraries for Pro*C and Oracle*XA clients. Shared object code is compatible with the archive library. Shared libraries, however, are organized and linked differently from archive libraries.

Shared objects are dynamically linked and appear as a single object file containing code for every function in the library. When your program uses a function from a shared object, the content of the shared library is placed into the virtual address space of your process at run time. In addition, other programs use the code in the shared objects simultaneously at run time.

Shared libraries provide the following advantages over archives:

Creating the Shared Library for Pro*C and Oracle*XA Clients

To use shared code in a program:

$ORACLE_HOME/lib/libclntsh.so is the shared library for Oracle7 on UNIX. If you install Pro*C, the library is generated automatically by the Oracle Installer during a fresh installation. If necessary, you can also generate the library manually, using the clntsh.mk makefile in $ORACLE_HOME/rdbms/lib.

Attention: Make sure no applications using libclntsh.so are running when you rebuild libclntsh.so.

Oracle7 and Pro*C products must be installed before the shared library is generated. If you install Oracle*XA later, the Oracle Installer re-runs the makefile to include Oracle*XA in the shared library.

You must rebuild the client-side shared library when you:

To rebuild the shared library manually, verify that the environment variable ORACLE_HOME is set and complete the following steps:

Example:

$ cd $ORACLE_HOME/rdbms/lib
$ make -f clntsh.mk libclntsh

Creating Executables that Use the Shared Library

To generate executables for Pro*C and Oracle*XA programs, use $ORACLE_HOME/proc/lib/proc.mk as a makefile. A target build exists for this purpose. The EXE and OBJS variables are passed to the make command to specify the client to be built. For example:

	% make -f $ORACLE_HOME/proc/lib/proc.mk \ 
	  ORA_CLIENT_LIB=shared OBJS=foo.o EXE=foo

You can also set the variable ORA_CLIENT_LIB in your environment, then generate the executable without explicitly passing in the environment variable. For example:

	% make -f $ORACLE_HOME/proc/lib/proc.mk OBJS=foo.o \ 
	  EXE=foo

Using Shared Code at Runtime

At runtime, the operating system's dynamic linker must be able to find all shared objects used by an executable. You can use one of the following methods to set the search path to $ORACLE_HOME/lib for libclntsh.so.

See Also: The UNIX man page for the ldd command.

If the dynamic linker is unable to find the shared object, a message similar to the following appears:

$ ./sample1 
  ld.so.1: sample1: fatal: libclntsh.so: 
  can't open file: errno=2 
  Killed 

Restrictions

Oracle*XA does not support the use of package global variables.


Contents Index Home Previous Next