* compile and link a C with embedded SQl program using gcc and DB2
@ 2004-08-19 18:44 Sinha, Vinita
2004-08-20 6:49 ` Eljay Love-Jensen
0 siblings, 1 reply; 3+ messages in thread
From: Sinha, Vinita @ 2004-08-19 18:44 UTC (permalink / raw)
To: gcc-help
Hi,
I am trying to compile a simple sql program using c and DB2 . It fails in the link step.Which are the other Libraries I need to add in the link step to make it work ?
This is the bat file for compile
@echo off
rem Licensed Materials - Property of IBM
if exist "%1.sqx" goto embedded
if exist "%1.sqc" goto embedded
goto non_embedded
:embedded
rem Precompile and bind the program.
call embprep %1 %2 %3 %4
rem Compile the program.
if exist "%1.cxx" goto cpp_emb
goto link_embedded
:cpp_emb
rem Link the program.
:link_embedded
gcc -I"C:\Program Files\SQLLIB\include" -I"C:\Program Files\SQLLIB\samples\c" -I"C:\Program Files\SQLLIB\samples\cli" -O0 -g3 -Wall -c -fmessage-length=0 -osqlexample.o sqlexample.c
gcc -L"C:\Program Files\SQLLIB\include" -L"C:\Program Files\SQLLIB\lib\db2api.lib" -L"C:\Program Files\SQLLIB\samples\c" -L"C:\Program Files\SQLLIB\bin" -o2006b.exe sqlexample.o
goto exit
The compile log with errors :
C:\R20006\cPrograms>bldappgcc.bat sqlexample Replica1 db2admin db2admin
Database Connection Information
Database server = DB2/NT 8.1.0
SQL authorization ID = DB2ADMIN
Local database alias = REPLICA1
LINE MESSAGES FOR sqlexample.sqc
------ --------------------------------------------------------------------
SQL0060W The "C" precompiler is in progress.
SQL0091W Precompilation or binding was ended with "0"
errors and "0" warnings.
LINE MESSAGES FOR sqlexample.bnd
------ --------------------------------------------------------------------
SQL0061W The binder is in progress.
SQL0091N Binding was ended with "0" errors and "0" warnings.
DB20000I The SQL command completed successfully.
C:\R20006\cPrograms>rem Compile the program.
C:\R20006\cPrograms>if exist "sqlexample.cxx" goto cpp_emb
C:\R20006\cPrograms>goto link_embedded
C:\R20006\cPrograms>gcc -I"C:\Program Files\SQLLIB\include" -I"C:\Program Files\
SQLLIB\samples\c" -I"C:\Program Files\SQLLIB\samples\cli" -O0 -g3 -Wall -c -fmes
sage-length=0 -osqlexample.o sqlexample.c
sqlexample.sqc:73:18: warning: character constant too long for its type
sqlexample.sqc:73:30: warning: character constant too long for its type
sqlexample.sqc:73:42: warning: character constant too long for its type
sqlexample.sqc: In function `main':
sqlexample.sqc:73: warning: passing arg 1 of `DbConnect' makes pointer from inte
ger without a cast
sqlexample.sqc:73: warning: passing arg 2 of `DbConnect' makes pointer from inte
ger without a cast
sqlexample.sqc:73: warning: passing arg 3 of `DbConnect' makes pointer from inte
ger without a cast
sqlexample.sqc:87: warning: control reaches end of non-void function
sqlexample.sqc: In function `TbBasicSelect':
sqlexample.sqc:121: warning: unused variable `rc'
C:\R20006\cPrograms>gcc -L"C:\Program Files\SQLLIB\include" -L"C:\Program Files\
SQLLIB\lib\db2api.lib" -L"C:\Program Files\SQLLIB\samples\c" -L"C:\Program File
s\SQLLIB\bin" -o2006b.exe sqlexample.o
sqlexample.o(.text+0xce): In function `main':
/cygdrive/c/R20006/cPrograms/sqlexample.sqc:84: undefined reference to `_sqlastr
t@12'
sqlexample.o(.text+0xfd):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:84: undefin
ed reference to `_sqlacall@20'
sqlexample.o(.text+0x10c):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:84: undefi
ned reference to `_sqlastop@4'
sqlexample.o(.text+0x24a): In function `DbConnect':
/cygdrive/c/R20006/cPrograms/sqlexample.sqc:105: undefined reference to `_sqlast
rt@12'
sqlexample.o(.text+0x271):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:105: undef
ined reference to `_sqlaaloc@16'
sqlexample.o(.text+0x31c):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:105: undef
ined reference to `_sqlasetda@24'
sqlexample.o(.text+0x34b):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:105: undef
ined reference to `_sqlacall@20'
sqlexample.o(.text+0x35a):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:105: undef
ined reference to `_sqlastop@4'
sqlexample.o(.text+0x380):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:111: undef
ined reference to `_sqlastrt@12'
sqlexample.o(.text+0x3a7):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:111: undef
ined reference to `_sqlaaloc@16'
sqlexample.o(.text+0x406):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:111: undef
ined reference to `_sqlasetda@24'
sqlexample.o(.text+0x435):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:111: undef
ined reference to `_sqlacall@20'
sqlexample.o(.text+0x444):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:111: undef
ined reference to `_sqlastop@4'
sqlexample.o(.text+0x4b1): In function `TbBasicSelect':
/cygdrive/c/R20006/cPrograms/sqlexample.sqc:126: undefined reference to `_sqlast
rt@12'
sqlexample.o(.text+0x4d8):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:126: undef
ined reference to `_sqlaaloc@16'
sqlexample.o(.text+0x538):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:126: undef
ined reference to `_sqlasetda@24'
sqlexample.o(.text+0x567):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:126: undef
ined reference to `_sqlacall@20'
sqlexample.o(.text+0x576):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:126: undef
ined reference to `_sqlastop@4'
collect2: ld returned 1 exit status
C:\R20006\cPrograms>rem link -debug -out:sqlexample.exe sqlexample.obj utilemb.o
bj db2api.lib
C:\R20006\cPrograms>goto exit
The system cannot find the batch label specified - exit
C:\R20006\cPrograms>
Any help will be appreciated
Thanks
Vinita
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: compile and link a C with embedded SQl program using gcc and DB2
2004-08-19 18:44 compile and link a C with embedded SQl program using gcc and DB2 Sinha, Vinita
@ 2004-08-20 6:49 ` Eljay Love-Jensen
0 siblings, 0 replies; 3+ messages in thread
From: Eljay Love-Jensen @ 2004-08-20 6:49 UTC (permalink / raw)
To: Sinha, Vinita, gcc-help
Hi Vinita,
The errors are DB2 errors, not GCC errors.
Unless there happens to be somebody on this forum with DB2 experience in
the particular environment you are working in (doubtful, but could happen),
you'll probably have better luck inquiring on a DB2 help forum.
Sincerely,
--Eljay
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: compile and link a C with embedded SQl program using gcc and DB2
@ 2004-08-20 8:03 Bras, Gerard
0 siblings, 0 replies; 3+ messages in thread
From: Bras, Gerard @ 2004-08-20 8:03 UTC (permalink / raw)
To: Sinha, Vinita, gcc-help
Vinita,
You are lacking the "-l" lib directives on your link line. You have the "-L" directives which tell the link WHERE to look. But you also need to specify WHICH actual libraries to link in. I don't know a thing about DB2 on NT but my guess is it'll be pretty obvious when you look in If it isn't there is always the DB2 web site which I'm has what you're looking for.
Acutally, now that I look closer you seem to have tried to combine bothe functions into a single "-L" directive. Try changing:
-L"C:\Program Files\SQLLIB\lib\db2api.lib
into
-L"C:\Program Files\SQLLIB\lib" -ldb2api.lib
Best of luck.
Gerard Bras
-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]On
Behalf Of Sinha, Vinita
Sent: Thursday, August 19, 2004 2:30 PM
To: gcc-help@gcc.gnu.org
Subject: compile and link a C with embedded SQl program using gcc and
DB2
Hi,
I am trying to compile a simple sql program using c and DB2 . It fails in the link step.Which are the other Libraries I need to add in the link step to make it work ?
This is the bat file for compile
@echo off
rem Licensed Materials - Property of IBM
if exist "%1.sqx" goto embedded
if exist "%1.sqc" goto embedded
goto non_embedded
:embedded
rem Precompile and bind the program.
call embprep %1 %2 %3 %4
rem Compile the program.
if exist "%1.cxx" goto cpp_emb
goto link_embedded
:cpp_emb
rem Link the program.
:link_embedded
gcc -I"C:\Program Files\SQLLIB\include" -I"C:\Program Files\SQLLIB\samples\c" -I"C:\Program Files\SQLLIB\samples\cli" -O0 -g3 -Wall -c -fmessage-length=0 -osqlexample.o sqlexample.c
gcc -L"C:\Program Files\SQLLIB\include" -L"C:\Program Files\SQLLIB\lib\db2api.lib" -L"C:\Program Files\SQLLIB\samples\c" -L"C:\Program Files\SQLLIB\bin" -o2006b.exe sqlexample.o
goto exit
The compile log with errors :
C:\R20006\cPrograms>bldappgcc.bat sqlexample Replica1 db2admin db2admin
Database Connection Information
Database server = DB2/NT 8.1.0
SQL authorization ID = DB2ADMIN
Local database alias = REPLICA1
LINE MESSAGES FOR sqlexample.sqc
------ --------------------------------------------------------------------
SQL0060W The "C" precompiler is in progress.
SQL0091W Precompilation or binding was ended with "0"
errors and "0" warnings.
LINE MESSAGES FOR sqlexample.bnd
------ --------------------------------------------------------------------
SQL0061W The binder is in progress.
SQL0091N Binding was ended with "0" errors and "0" warnings.
DB20000I The SQL command completed successfully.
C:\R20006\cPrograms>rem Compile the program.
C:\R20006\cPrograms>if exist "sqlexample.cxx" goto cpp_emb
C:\R20006\cPrograms>goto link_embedded
C:\R20006\cPrograms>gcc -I"C:\Program Files\SQLLIB\include" -I"C:\Program Files\
SQLLIB\samples\c" -I"C:\Program Files\SQLLIB\samples\cli" -O0 -g3 -Wall -c -fmes
sage-length=0 -osqlexample.o sqlexample.c
sqlexample.sqc:73:18: warning: character constant too long for its type
sqlexample.sqc:73:30: warning: character constant too long for its type
sqlexample.sqc:73:42: warning: character constant too long for its type
sqlexample.sqc: In function `main':
sqlexample.sqc:73: warning: passing arg 1 of `DbConnect' makes pointer from inte
ger without a cast
sqlexample.sqc:73: warning: passing arg 2 of `DbConnect' makes pointer from inte
ger without a cast
sqlexample.sqc:73: warning: passing arg 3 of `DbConnect' makes pointer from inte
ger without a cast
sqlexample.sqc:87: warning: control reaches end of non-void function
sqlexample.sqc: In function `TbBasicSelect':
sqlexample.sqc:121: warning: unused variable `rc'
C:\R20006\cPrograms>gcc -L"C:\Program Files\SQLLIB\include" -L"C:\Program Files\
SQLLIB\lib\db2api.lib" -L"C:\Program Files\SQLLIB\samples\c" -L"C:\Program File
s\SQLLIB\bin" -o2006b.exe sqlexample.o
sqlexample.o(.text+0xce): In function `main':
/cygdrive/c/R20006/cPrograms/sqlexample.sqc:84: undefined reference to `_sqlastr
t@12'
sqlexample.o(.text+0xfd):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:84: undefin
ed reference to `_sqlacall@20'
sqlexample.o(.text+0x10c):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:84: undefi
ned reference to `_sqlastop@4'
sqlexample.o(.text+0x24a): In function `DbConnect':
/cygdrive/c/R20006/cPrograms/sqlexample.sqc:105: undefined reference to `_sqlast
rt@12'
sqlexample.o(.text+0x271):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:105: undef
ined reference to `_sqlaaloc@16'
sqlexample.o(.text+0x31c):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:105: undef
ined reference to `_sqlasetda@24'
sqlexample.o(.text+0x34b):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:105: undef
ined reference to `_sqlacall@20'
sqlexample.o(.text+0x35a):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:105: undef
ined reference to `_sqlastop@4'
sqlexample.o(.text+0x380):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:111: undef
ined reference to `_sqlastrt@12'
sqlexample.o(.text+0x3a7):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:111: undef
ined reference to `_sqlaaloc@16'
sqlexample.o(.text+0x406):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:111: undef
ined reference to `_sqlasetda@24'
sqlexample.o(.text+0x435):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:111: undef
ined reference to `_sqlacall@20'
sqlexample.o(.text+0x444):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:111: undef
ined reference to `_sqlastop@4'
sqlexample.o(.text+0x4b1): In function `TbBasicSelect':
/cygdrive/c/R20006/cPrograms/sqlexample.sqc:126: undefined reference to `_sqlast
rt@12'
sqlexample.o(.text+0x4d8):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:126: undef
ined reference to `_sqlaaloc@16'
sqlexample.o(.text+0x538):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:126: undef
ined reference to `_sqlasetda@24'
sqlexample.o(.text+0x567):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:126: undef
ined reference to `_sqlacall@20'
sqlexample.o(.text+0x576):/cygdrive/c/R20006/cPrograms/sqlexample.sqc:126: undef
ined reference to `_sqlastop@4'
collect2: ld returned 1 exit status
C:\R20006\cPrograms>rem link -debug -out:sqlexample.exe sqlexample.obj utilemb.o
bj db2api.lib
C:\R20006\cPrograms>goto exit
The system cannot find the batch label specified - exit
C:\R20006\cPrograms>
Any help will be appreciated
Thanks
Vinita
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-08-19 18:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-19 18:44 compile and link a C with embedded SQl program using gcc and DB2 Sinha, Vinita
2004-08-20 6:49 ` Eljay Love-Jensen
2004-08-20 8:03 Bras, Gerard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).