Here's a short/long question...

Short: How do you properly compile C code into a shared object (DLL) so that Cache will load it?  This is really probably a Linux/Unix/Gcc question, but I was hoping some Cache guru's would have some pointers...

Long:
We have an external package that is used to track Immunization history, it's written in C, compiled as a .DLL or .SO (NT vs. Unix) and called into our RPMS box.  Two years ago we compiled and installed a version with Sun's 'cc', and had no troubles.  Recently the developer released a newer version of the software, but he only likes to support NT/AIX ( and we run Solaris 9 on a Sparc 64 ).  We installed GCC used his 'make' file, and got it to compile:

The makefiles (old/new), identical except for the compiler.  I did some Googling and found quite a few references to GCC flags for .so's.  So I added the flags (-fPIC and -shared) to the makefile, and tested compiling.  Seemed to work fine...
-------
 bash-2.05# diff /opt/cache/fred/MDA_src_0406/makefile 
 /opt/cache/luke/MDA_src_0406/makefile
 28c28,29
 < CC = gcc -m64
 ---

 > #CC = gcc -m64
 > CC = gcc -m64 -fPIC

 52c53
 <               $(CC)   -G  -o bisolarisc.so \
 ---

 >               $(CC)   -shared -G  -o bisolarisc.so \

 bash-2.05#

 bash-2.05# pwd
 /opt/cache/luke/MDA_src_0406
 bash-2.05# make
 gcc -m64 -fPIC -DUNIX_VERS -DTWOPASS -c -I. cache_ascii_if.c
 gcc -m64 -fPIC -DUNIX_VERS -DTWOPASS -c -I. aconvert.c
 gcc -m64 -fPIC -DUNIX_VERS -DTWOPASS -DBUF_DEF -DGLOBAL_DEF -c -I. cas3_lib.c
 gcc -m64 -fPIC -DUNIX_VERS -DTWOPASS -c -I. filters.c
 gcc -m64 -fPIC -DUNIX_VERS -DTWOPASS -c -I. lib_init.c
 gcc -m64 -fPIC -DUNIX_VERS -DTWOPASS -c -I. mtimefun.c
 gcc -m64 -fPIC -DUNIX_VERS -DTWOPASS -c -I. tables.c
 gcc -m64 -fPIC -DUNIX_VERS -DTWOPASS -c -I. gen_fact.c
 gcc -m64 -fPIC -DUNIX_VERS -DTWOPASS -c -I. ll_funcs.c
 gcc -m64 -fPIC -DUNIX_VERS -DTWOPASS -DIHSREPORT -c -I. ihsrptwr.c
 gcc -m64 -fPIC  -shared -G  -o bisolarisc.so \
                 cache_ascii_if.o aconvert.o cas3_lib.o filters.o \
                 lib_init.o mtimefun.o tables.o \
                 gen_fact.o ll_funcs.o ihsrptwr.o
 bash-2.05#


However, Cache doesn't like to load it; from the routine that loads the DLL:
-------
S BIDLLID=$ZF(-4,1,BIDLLPROG)
^
<DYNAMIC LIBRARY LOAD>LOAD+14^BIXCALL

SEARHC 15d1>W BIDLLPROG
/db/forecaster/bisolarisc.so


Rather nondescript error. That's with the 'new' DLL, just to make sure I loaded the 'old' DLL by hand:
-------
SEARHC 15d1>S BIDLLID=$ZF(-4,1,"/db/forecaster/bisolarisc-old.so")

SEARHC 15d1>W BIDLLID
122768


I got back the 'handle' from Cache, thats good.
I eventually found what I think is the problem...
-------
bash-2.05# tail -f /opt/cache/mgr/cconsole.log
07/03-16:25:02:979 (13186) 0 Error loading dll (/opt/cache/luke/MDA_src_0406/bisolarisc.so) is: ld.so.1: cache: fatal: libgcc_s.so.1: open failed: No such file or directory

bash-2.05# ldd /opt/cache/luke/MDA_src_0406/bisolarisc.so
        libgcc_s.so.1 =>         (file not found)
bash-2.05#


Ahh, it can't find the GCC libs.... I can fix that...
-------
bash-2.05# export LD_LIBRARY_PATH=/usr/local/lib:~/lib


No luck...
-------
bash-2.05# tail -f /opt/cache/mgr/cconsole.log
07/03-16:26:31:562 (13272) 0 Error loading dll (/opt/cache/luke/MDA_src_0406/bisolarisc.so) is: ld.so.1: cache: fatal: /usr/local/lib/libgcc_s.so.1: wrong ELF class: ELFCLASS32

bash-2.05# ldd /opt/cache/luke/MDA_src_0406/bisolarisc.so
        libgcc_s.so.1 =>         /usr/local/lib/libgcc_s.so.1  - wrong 
ELF class: ELFCLASS32
bash-2.05#


So, here I am, a bit stumped...  The only thing I can guess is that GCC doesn't like compiling .so's on our 64bit Solaris box, or maybe that GCC links to a 32bit library somewhere else?  FWIW:
-------
bash-2.05# gcc -v
Reading specs from /opt/local/bin/../lib/gcc-lib/sparc-sun-solaris2.9/3.2/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --disable-nls
Thread model: posix
gcc version 3.2
bash-2.05#

I also compiled this on a different Solaris 9 Sparc64 box with GCC 3.3, same result.
I'll confess, I didn't build GCC and all it's libs by hand, I was a bum and got the packages from http://www.sunfreeware.com/programlistsparc9.html#gcc33 .
Lastly, of course the new code isn't completely untested.  It is in production on both AIX/NT boxes, and is even rumored to work with GT.M on a Linux box.

Anybody have much experience compiling .so's on Linux/Aix/Solaris/etc, especially with GCC and Sparc64?
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Hardhats-members mailing list
Hardhats-members@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hardhats-members

Reply via email to