Re: esql/c compilation problem
Posted in 1997
>From: JEAN-FRANCOIS_LE-CARRE-PETIT@non-hp-france-om4.om.hp.com >Date: Fri, 4 Apr 97 14:22:37 +0200 >X-Informix-List-Id: <list.13857> > >Hello, > >I have a problem in execution of an esql/c program in Informix Online 7.13 >UC3. INFORMIXDIR is not the same on development machine and production >machine. When this program is executed on the production machine, we get an >error with the shared libraries that it doesn't find ! > >It seems that INFORMIXDIR is stored in the executable file !!! Yes, that's exactly the problem...more or less. Specifically, the exact location of the libraries is stored in the executable. and the directory where they are located is a sub-directory of $INFORMIXDIR on the machine where the binaries are linked. The problem is in the ESQL/C script. When the 7.1x script specifies the shared libraries to be linked, it specifies them by the full path name, just as it specifies the static libraries by full pathname. This is always a mistake -- and it has been fixed in the 7.2x releases. What can you do to get around the problem? There are a number of options. One is to upgrade to 7.2x. Another is to use static linking instead of dynamic linking. Yet another is to create a symlink on the production machine such that the shared libraries appear in the same place as on the development machine. For example, if the development machine has $INFORMIXDIR set to /usr/informix/7.13.UC3 and the production machine has $INFORMIXDIR set to /opt/informix, then on the production machine as a suitably privileged user (eg root), you could do: mkdir -p /usr/informix/7.13.UC3 ln -s /opt/informix/lib /usr/informix/7.13.UC3/lib chmod 555 /usr/informix/7.13.UC3 chown informix /usr/informix/7.13.UC3 chgrp informix /usr/informix/7.13.UC3 When the exectuables are run, they'll read /usr/informix/7.13.UC1/lib, follow the symlink to /opt/informix/lib and then find the real library. Yet another option (in some ways the best, in others the worst), is to fix the ESQL/C script so that it handles shared libraries correctly. It should refer to the libraries at link time using the -los -lgen -lsql, notation, and add the -L$INFORMIXDIR/lib -L$INFORMIXDIR/lib/esql options to the link line. The downside to this is that you've modified what was released (but you did keep a copy of the original, didn't you), which reduces the supportability. The upside is that you don't have to make the symlinks. One part which of the problem which you need to be aware of is that there is a system library called libgen.so on SVR4 machines, and this collides with the name of the Informix libgen.so (libgen.sl for HP-UX). If you are linking with -lgen, you are going to get one or the other of the two libgen libraries, and not both. This problem affects NewEra; we get around it by linking with the static system libgen.a. In the 7.2x release, the Informix libraries all have names such as libixgen.s{o|l}, which avoids that problem for the most part, except that that libgen.s{o|l} name also exists for 'backwards compatability' and therefore means that you still can't use the system libgen with the -lgen option because the ESQL/C libgen will be picked up first. Oh well... You could do this renaming manually, of course, but you'd have to do it on the production machines too. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>