Re: Which Oracle libs to link with Pro*C program?
Date: 1998/03/19
Message-ID: <35114969.80C8AC3E_at_fairway.com>#1/1
Zoran wrote:
>
> I'm currently getting by with using a modified version of the Oracle
> supplied Makefile sample on AIX 4.1. However the binary for my rather simple
> program is 2.4M in size. I also notice that the Oracle Makefile links
> in -many- libraries, many of which I'm sure aren't necessary.
Probably, the majority are necessary. Have you looked at the pro*c demo makefiles?
> How can I find out which libraries are to be used when? I believe I have the
> full Oracle 7 server documentation set and have poured over it extensively
> for such information and haven't found any. There are probably about 20
> libraries in $ORACLE_HOME/lib many of which get linked in using the Oracle
> supplied makefile.
Well, Unix linkers are single-pass when they resolve symbols. This means that references between oracle libraries requires libraries to be included more than once. For example, if you look at the pro*c demo makefile, there are several libraries included twice.
If you really want to eliminate the libraries, there are 2 ways to find out which ones you don't need:
- Trial-and-error -- try linking your executable via eliminating one library at a time. If you see unresolved symbol reference errors reported by the linker, then you know you need to keep this library. Unfortunately, this is painful because of the 'single-pass' problem -- i.e., you may not be able to eliminate a library because a library you need depends on calls to the library you wish to eliminate:
libA -- could remove libB -- needed for your executable, but makes calls to libA
net result: both libraries are needed.
2. Use the 'nm' command to find symbols in libraries. I had to do this a lot at my previous job, so I wrote a shell script. It is included at the bottom of this post. I also included 'symbols.in' and 'libraries.in'. symbols.in contains a list of symbols that I am looking to resolve and libraries.in contains a list of libraries to look in for the symbol list.
Good luck.
Jeff
-- Jeffery C. Cann Senior Software Engineer Fairway Systems, Inc. ---------------------- start shell script 'findit' --------------------- #!/bin/ksh # # Program: findit # # Description: findit will use an input file of libraries to find the symbols # in the input file list of symbols # # Usage: findit [symbol-name] [library_lookup_list] # # Modification History: # # 24-Jul-1997 Jeffery C. Cann # -Created. # ############################################################################# # check for parameters if [ $# -eq 0 ] then echo "findit: Usage:" echo "findit: findit [symbol-name-list] [library-lookup-list] " exit 1 fi # # This will loop through the names in the library-lookup-list (file) # and search each library for the symbols in the symbol-name-list (file) # # $1 is the file which contains the list of symbols to find # $2 is the list of libraries to search using the 'nm' command # for LIB_FILE_NAME in $2 do nm $LIB_FILE_NAME | grep $1 done exit 0 -------------------------- start input file symbols.in ---------- # These are symbols (functions) that I want to search for in the list # of libraries in libraries.in ag_getxmitslot ag_unlisten ag_listen dx_unlisten dx_getxmitslot dx_listen -------------------------- start input file libraries.in -------- # These are all the libraries in my /usr/lib # This is a SCO UNIX machine # generated by ls /usr/lib > libraries.in # /usr/lib/lib300.a /usr/lib/lib300s.a /usr/lib/lib4014.a /usr/lib/lib450.a /usr/lib/libcurses.a /usr/lib/libdbm.a /usr/lib/libdti.a /usr/lib/libdxxx.a /usr/lib/libform.a /usr/lib/libg.a /usr/lib/libgen.a /usr/lib/libgncf.a /usr/lib/libintlstub.a /usr/lib/libisam.a /usr/lib/libl.a /usr/lib/libmalloc.a /usr/lib/libmenu.a /usr/lib/libnls.a /usr/lib/libnsl_s.a /usr/lib/libpanel.a /usr/lib/libplot.a /usr/lib/libprof.a /usr/lib/libpt.a /usr/lib/libsbd.a /usr/lib/libsec.a /usr/lib/libsrl.a /usr/lib/libtam.a /usr/lib/libtcap.a /usr/lib/libtermcap.a /usr/lib/libtermlib.a /usr/lib/libtinfo.a /usr/lib/libvt0.a /usr/lib/libwindows.a /usr/lib/liby.aReceived on Thu Mar 19 1998 - 00:00:00 CET