Newbie and GCC/ESQL Problem
Posted in 1999
Topics: High Availability & Replication, Installation, Setup & Upgrades, Connectivity: ESQL/C, 4GL & Embedded SQL, Platform-Specific Issues
Hi, I installed Informix-SE that came with my SuSE Linux 6.0 distribution. The installation worked well. I first installed ESQL/C than Informix-SE the way it was described in a README. I then wrote a little ESQL/C program (test.ec) to try if everything was right. main () { EXEC SQL connect to 'carvalho@demo_se'; EXEC SQL disconnect current; } I then compiled it with: esql test.ec. No problem, this gave me the test.c file I then tried to compile the medecin.c file produced with the previous command. gcc -ansi -o test test.c First the compiler said he was not able to find two header files (I think it was SQLAPI.H and SQLHDR.H). So I edited the file test.c and put the complete path to the two header files: I replaced #INCLUDE <SQLAPI.H> with #INCLUDE "/usr/lib/informix/incl/esql/sqlapi.h" (same for the other one) I retried to compile the test.c file and this time I got errors for each of the SQL commands: Something like "unreferenced symbol "sqli_connect"" I think that gcc can't find the esql librairies but I don't know what I can do.
Xaendiss wrote: > > Hi, > > I installed Informix-SE that came with my SuSE Linux 6.0 distribution. > The installation worked well. I first installed ESQL/C than Informix-SE > the way it was described in a README. > > I then wrote a little ESQL/C program (test.ec) to try if everything was > right. > > main () { > > EXEC SQL connect to 'carvalho@demo_se'; > > EXEC SQL disconnect current; > } > > I then compiled it with: esql test.ec. No problem, this gave me the > test.c file > > I then tried to compile the medecin.c file produced with the previous > command. > > gcc -ansi -o test test.c > > First the compiler said he was not able to find two header files (I > think it was > SQLAPI.H and SQLHDR.H). > > So I edited the file test.c and put the complete path to the two header > files: > I replaced > > #INCLUDE <SQLAPI.H> with #INCLUDE "/usr/lib/informix/incl/esql/sqlapi.h" > > (same for the other one) > > I retried to compile the test.c file and this time I got errors for each > of the SQL commands: > > Something like "unreferenced symbol "sqli_connect"" > > I think that gcc can't find the esql librairies but I don't know what I > can do. ESQL is a complete compiler driver, like gcc, so you do not have to compile the .c file it was just left around for debugging purposes. The command you executed, esql test.ec, produced an executable named a.out which is the UNIX standard for unnamed executables. You can add the -o <execname> option to esql and it will produce what you expect: esql -o test test.ec Of course the shell built-in function 'test' will give you trouble when you try to run this beasty but a bit of creative renaming will solve that and is left for an exercise. Art S. Kagel
Xaendiss wrote: > I installed Informix-SE that came with my SuSE Linux 6.0 distribution. > The installation worked well. I first installed ESQL/C than > Informix-SE the way it was described in a README. > > I then wrote a little ESQL/C program (test.ec) to try if everything > was right. > > main () { > > EXEC SQL connect to 'carvalho@demo_se'; > > EXEC SQL disconnect current; > } > > I then compiled it with: esql test.ec. No problem, this gave me the > test.c file And the test.o file, and a.out the executable program to run. > I then tried to compile the medecin.c file produced with the previous > command. > > gcc -ansi -o test test.c > > First the compiler said he was not able to find two header files (I > think it was > SQLAPI.H and SQLHDR.H). Sounds about right; they include numerous other files. But you don't use GCC to compile the generated C file; you use the esql script because it does the job properly for you. And normally, you'd simply use: esql -c test.ec to generate test.o; or you'd use: esql -o mytest test.ec to create named program. You don't call your program test unless you're into sado-masochism or you like typing ./test all the time. > So I edited the file test.c and put the complete path to the two header > files: > I replaced > > #INCLUDE <SQLAPI.H> with #INCLUDE "/usr/lib/informix/incl/esql/sqlapi.h" > > (same for the other one) Extremely bad idea, and it might not fix the other headers. Although, given the way GCC works, it might. Reasoning supplied on request. > I retried to compile the test.c file and this time I got errors > for each of the SQL commands: > > Something like "unreferenced symbol "sqli_connect"" OK: GCC worked around the lack of the -I option. As mentioned previously, the esql script does the job correctly. Never, ever, try to second guess the esql script when it comes to the library list. Your makefile will break at the next update. > I think that gcc can't find the esql librairies but I don't know > what I can do. Use the esql script to do the compilation: esql -o mytest test.ec -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN #include <disclaimer.h>
Thanx everybody, I didn't notice that esql was able to compile to an executable. Everything works fine now Jonathan Leffler wrote: > Xaendiss wrote: > > I installed Informix-SE that came with my SuSE Linux 6.0 distribution. > > The installation worked well. I first installed ESQL/C than > > Informix-SE the way it was described in a README. > > > > I then wrote a little ESQL/C program (test.ec) to try if everything > > was right. > > > > main () { > > > > EXEC SQL connect to 'carvalho@demo_se'; > > > > EXEC SQL disconnect current; > > } > > > > I then compiled it with: esql test.ec. No problem, this gave me the > > test.c file > > And the test.o file, and a.out the executable program to run. > > > I then tried to compile the medecin.c file produced with the previous > > command. > > > > gcc -ansi -o test test.c > > > > First the compiler said he was not able to find two header files (I > > think it was > > SQLAPI.H and SQLHDR.H). > > Sounds about right; they include numerous other files. But you don't > use GCC to compile the generated C file; you use the esql script > because it does the job properly for you. > > And normally, you'd simply use: > > esql -c test.ec > > to generate test.o; or you'd use: > > esql -o mytest test.ec > > to create named program. You don't call your program test unless > you're into sado-masochism or you like typing ./test all the time. > > > So I edited the file test.c and put the complete path to the two header > > files: > > I replaced > > > > #INCLUDE <SQLAPI.H> with #INCLUDE "/usr/lib/informix/incl/esql/sqlapi.h" > > > > (same for the other one) > > Extremely bad idea, and it might not fix the other headers. Although, > given the way GCC works, it might. Reasoning supplied on request. > > > I retried to compile the test.c file and this time I got errors > > for each of the SQL commands: > > > > Something like "unreferenced symbol "sqli_connect"" > > OK: GCC worked around the lack of the -I option. > > As mentioned previously, the esql script does the job correctly. > Never, ever, try to second guess the esql script when it comes to > the library list. Your makefile will break at the next update. > > > I think that gcc can't find the esql librairies but I don't know > > what I can do. > > Use the esql script to do the compilation: > > esql -o mytest test.ec > > -- > Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) > Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN > #include <disclaimer.h>