Using dlopen with Informix SDK on AIX
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Platform-Specific Issues
Environment: AIX 4.2 or 4.3, Informix SDK 2.10, 2.20 or 2.30 I have an application that runs on AIX 4.2 and on AIX 4.3 that connects to an Informix 7.X server. The application itself does not make any ESQL/C calls. All ESQL/C calls are made from my shared libraries. These shared libraries are not linked into the application at compile time, but are loaded at run-time using dlopen() / dlsym() calls. The shared libraries are linked with the Informix SDK libraries, and all object files that make up the shared libraries were compiled with esql -c. I have found that when I do not link the application with the Informix SDK libraries, the application aborts on the EXEC SQL CONNECT... call in the Informix GlobInit() function. If I do link the application with the Informix SDK libraries, the CONNECT statement executes successfully. If I use ESQL/C 7.1 or 7.2, I do not have to link my application with the Informix ESQL/C libraries. This only becomes a problem with SDK 2.10 and later. I also run this application on many other platforms -- Solaris, HP, DEC, Sequent, NT, etc. -- and am not having any problems with SDK 2.20 and CONNECT. I have a call into Informix tech support on this issue. They first suggested that I use the -brtl flag on AIX to build my application. But my application and shared libraries are already built with this flag (the shared libraries with -G, which, among other things, implies -brtl). Tech support's latest response is that I must build my application using the esql script (which would, in effect, link in the Informix SDK libraries), and that nothing else is supported. However, I can't build the application with esql because it is also used to connect to databases other than Informix such as Oracle, Sybase, etc. The application is passed the name of a configuration file that it reads to determine which set of shared libraries to load -- the ones for Informix, the ones for Oracle, etc. Has anyone else run into this problem, and found a work around? I can provide a short test program if you need more details. Thanks for any help, Grace
Grace Huntzinger wrote: > Environment: AIX 4.2 or 4.3, Informix SDK 2.10, 2.20 or 2.30 Fascinating problem! > I have an application that runs on AIX 4.2 and on AIX 4.3 that > connects to an Informix 7.X server. The application itself does > not make any ESQL/C calls. All ESQL/C calls are made from my > shared libraries. These shared libraries are not linked into > the application at compile time, but are loaded at run-time > using dlopen() / dlsym() calls. > > The shared libraries are linked with the Informix SDK libraries, > and all object files that make up the shared libraries were > compiled with esql -c. And, I trust, the shared library flags? That would be -fPIC or -KPIC on SVR4, not sure about AIX. > I have found that when I do not link the application with the > Informix SDK libraries, the application aborts on the EXEC SQL > CONNECT... call in the Informix GlobInit() function. Seems reasonable -- I'll get to why. > If I do link the application with the Informix SDK libraries, > the CONNECT statement executes successfully. Yes, that would work. The program knows about the symbols in the Informix shared libraries under this scenario. > If I use ESQL/C 7.1 or 7.2, I do not have to link my application > with the Informix ESQL/C libraries. This only becomes a problem > with SDK 2.10 and later. I also run this application on many other > platforms -- Solaris, HP, DEC, Sequent, NT, etc. -- and am not > having any problems with SDK 2.20 and CONNECT. I'm not sure why the problems don't show up on the other platforms. When you build your shared library which calls Informix code, do you list the Informix libraries on the command line? You should, and that means you should use the esql script to do it. You might have some problems getting a -G option pasr the esql compiler; it can be done by fudging the INFORMIXC environment variable. The key point is that your shared library must know how to resolve the Informix-related symbols, since your application will not have that information built in. Now, if you only have a single shared library which needs both Oracle and other shared libraries, then maybe you need to refactor the libraries somehow. > I have a call into Informix tech support on this issue. They first > suggested that I use the -brtl flag on AIX to build my application. > But my application and shared libraries are already built with this > flag (the shared libraries with -G, which, among other things, > implies -brtl). Tech support's latest response is that I must > build my application using the esql script (which would, in effect, > link in the Informix SDK libraries), and that nothing else is > supported. That is the normal response -- your requirements are not usual. > However, I can't build the application with esql because it is also > used to connect to databases other than Informix such as Oracle, > Sybase, etc. The application is passed the name of a configuration > file that it reads to determine which set of shared libraries to > load -- the ones for Informix, the ones for Oracle, etc. Some psrt of the system has to know which shared libraries have to be loaded to access Informix. If it can't be the application (and I can see why it cannot), then it has to be a shared library used by the application. > Has anyone else run into this problem, and found a work around? > I can provide a short test program if you need more details. If you need more help, contact me at the office email address. Include a case number so I can explain to Informix Tech Support as well. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN #include <disclaimer.h>