Instructions: Linking of shared oracle libraries !!!
From: Ari Suutari <ari_at_tahko.lpr.carel.fi>
Date: 16 Nov 1993 22:33:33 +0200
Message-ID: <2cbdetINNln3_at_tahko.lpr.carel.fi>
Date: 16 Nov 1993 22:33:33 +0200
Message-ID: <2cbdetINNln3_at_tahko.lpr.carel.fi>
After I responded to an article about shared libraries and Oracle databases, I have received multiple requests for scripts I used for linking of libraries. I have linked shared libraries for Oracle V7 on Alpha OSF/1 1.2, Oracle V6 on AIX 3.2 and ICL SVR4. First two ones have been working without problems (OSF/1 version for about two months and AIX version more than year) but ICL version was unstable (but the problem is in operating system, not in shared library itself). Outside of Unix world, I have also linked a shared Oracle library in VAX/VMS environment (which is much better than partial solution provided by Oracle). Since my AIX script seemed to be a little out-of-date for newer Oracle versions, I'll try to give instructions for linking libraries instead of posting a script which won't work. The procedure for linking a shared oracle library for AIX 3.2 is: 1) Find out library names that are normally required to link Oracle programs (something link liboracle.a, libsqlnet.a, libtcp.a, osntab.o, libsql14.a etc ...). 2) Find out function names required by Pro*C programs. You can do this by examining precompiled .c files or taking a look on sqlcpr.h header file distributed with oracle. (I think that all functions in sqlcpr.h are not required by Pro*C programs, so examining precompiled files might be better choice, if you have time for it). 3) Create an export file for shared library. The file should contain function names found in step 2, one function name at each row. Name this file "ora.exp". 4) Link shared library with following command: ld -T512 -H512 -bE:ora.exp -bM:SRE -o oralib_shr.o \ oracle_libraries_found_in_step_1 -lc This will create "oralib_shr.o", which is your new shared oracle library for linking programs. You can create an archive library from it (if you want) with "ar -cr libora.a oralib_shr.o". 5) Test application by linking it with shared library instead of original oracle libraries. In AIX, you can run into following problems: - Unresolved functions - Unresolved variables References to unresolved functions like ".appfo", ".iapprs" and "iapprval" are caused by including "sqlgt2" and "sqlpf2" in your orelib.exp file. Remove this and error will go away. Reference to unresolved variable "p_xargv" can be removed by creating a small C source file which contains int p_xargv; and linking it into your shared library with oracle libraries. These errors can occur, becouse linkers are more picky about input files when linking shared libraries. However, in most cases there are workarounds (or kludges) to get around them. Don't give up too easily !! Then the OSF/1 case: 1) Same as in AIX. 2) Create a C file (name it dummy.c) containing: dummy () { sqlcex (); sqlald (); sqlclu (); } This file is needed just to force OSF/1 linker to include all necessary functions from archive libraries. 3) Compile dummy.c with "cc -c dummy.c" 4) Link shared library with command: ld -shared -check_registry /usr/shlib/so_locations \Received on Tue Nov 16 1993 - 21:33:33 CET
-update_registry /usr/local/lib/so_locations \
-no_archive -o libora.so \
dummy.o \ oracle_libraries_found_in_step_1 \
-lm -lc
Maybe there is a nicer way to tell which functions must be included into shared library than using a dummy.c but I could not get things working in any other way. The so_locations -files are important if you want to use OSF/1 "quickstart" feature to speed up program start-up times. Remember that Oracle can find it hard to support you if you use shared libraries built yourself. So far, we here have had absolutely no problems and I seriously recommend using of shared libraries on all platforms you can since it radically cuts down software development time by reducing linking times. We use also HP-UX here, but linking of shared libraries is not possible on it, becouse the software should have been compiled with special option (+z or +Z) to be compatible with shared libraries (shame on you, HP !!). Speedy linkings, Ari --- Ari Suutari ari_at_tahko.lpr.carel.fi Carelcomp Oy Lappeenranta FINLAND