Re: ESQL/C Library Errors
Posted in 1996
Why do you think it is better to run the C compiler direct when you know the method that works? Never, ever try linking ESQL/C programs directly with the cc command. Always, but ALWAYS use the esql script to do the linking. If you don't, you run into library order problems, not to mention problems such as the fact that the libraries vary from release to release. The link order is also apt to vary depending on whether you are linking with static or shared libraries. And depending on what software is actually installed on your machine, you may need to use different sets of libraries. All in all, it is not worth trying to work out what the necessary cc command line is to get the program to link -- use the esql script which knows how to do it. If it gets it wrong, then you have cause for complaint. In your case, you should simply use: esql -g -o test test.c connect.ec Or, if it is being done by make: esql -g -c connect.ec rm -f connect.c cc -c test.c esql -o test test.o connect.o One advantage of this is that you don't have to worry about the -I options; the esql script gets that right for you too. Of course, you really need to ensure that the suffix list places .ec files ahead of .c files: .SUFFIXES: .SUFFIXES: .ec .c .o # Add other suffixes as needed. That way, if you fail to compile connect.o, the next build won't start with connect.c; it will always start with connect.ec. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> PS: Thanks for the version info and the key environment variable. PPS: It is usually not a good idea to call test programs test on Unix; the test command is built into the shell, so you have to run ./test to run the correct test program. >From: Richard Cave <rcave@condor.peregrine.com> >Date: Thu, 14 Nov 96 14:32:21 PST >X-Informix-List-Id: <list.12069> > >I am *trying* to link in the esql/c libraries when I compile two >different modules. One module (connect.ec) contains the esql/c specific >api calls while the other (test.c) contains normal c functions and calls. > >I am using the following to generate the binary: > esql -e -local connect.ec > esql -I/pnmsdb01/informix/incl/esql -g -Aa -c connect.c > cc -I/pnmsdb01/informix/incl/esql -g -Aa -c test.c > cc -I/pnmsdb01/informix/incl/esql -o test test.o connect.o -g > -Aa -L/pnmsdb01/informix/lib -L/pnmsdb01/informix/lib/esql > -lsql -los -lasf -lgen -los -lgen -lm -lV3 > >When I run the program, I get the following: > /lib/dld.sl: Unresolved symbol: t_errno (data) > from /pnmsdb01/informix/lib/libasf.sl > /lib/dld.sl: Unresolved symbol: tlispx_opvec (data) > from /pnmsdb01/informix/lib/libasf.sl > /lib/dld.sl: Unresolved symbol: meAlloc (code) > from /pnmsdb01/informix/lib/libasf.sl > IOT trap (core dumped) > >Obviously, if I compile using the following, the program will run: >esql -I/pnmsdb01/informix/incl/esql -o test test.o connect.o -g > -Aa -L/pnmsdb01/informix/lib -L/pnmsdb01/informix/lib/esql > >Does anyone know the correct sequence for the libs to include in cc? >I am missing the 'ixacursor.o' library but tried unsuccessfully to include >it. If necessary, I can provide the source code for the C modules in the >that I am trying to compile. > >fyi: >HP-UX A.09.04 >INFORMIX-ESQL Version 7.12.UC1 >SHLIB_PATH=$(INFORMIXDIR)/lib:$(INFORMIXDIR)/lib/esql: > /usr/lib/X11R5:/usr/lib/Motif1.2