Hi there,
The following is my first embedded SQL program on Windows, which is
coded by C language.
/* sample.sqc */
#include <stdio.h>
EXEC SQL INCLUDE SQLCA;
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL INCLUDE 'staff.h'; /* generated by db2dclgn */
EXEC SQL END DECLARE SECTION;
int main(int argc, char *argv[])
{
EXEC SQL
select dept into :staff.dept
from staff
where id = 10;
printf("The ID no. of Sanders is: %d\n", staff.dept);
return 0;
}
I did db2 prep and bind commands successfully. But when I did the
compiling as below,
D:\Dev-Cpp\bin>gcc.exe "D:\Dev-Cpp\c\sample.c" -o "D:\Dev-Cpp\c
\sample.exe" -I"D:\SQLLIB\include" -L"D:\SQLLIB\lib"
The execution was terminated. It threw the messages as below,
C:\DOCUME~1\db2admin\LOCALS~1\Temp/ccCMaaaa.o(.text+0x42):sample.c:
undefined reference to `sqlastrt@12'
C:\DOCUME~1\db2admin\LOCALS~1\Temp/ccCMaaaa.o(.text+0x69):sample.c:
undefined reference to `sqlaaloc@16'
C:\DOCUME~1\db2admin\LOCALS~1\Temp/ccCMaaaa.o(.text+0xba):sample.c:
undefined reference to `sqlasetda@24'
C:\DOCUME~1\db2admin\LOCALS~1\Temp/ccCMaaaa.o(.text+0xe9):sample.c:
undefined reference to `sqlacall@20'
C:\DOCUME~1\db2admin\LOCALS~1\Temp/ccCMaaaa.o(.text+0xf8):sample.c:
undefined reference to `sqlastop@4'
collect2: ld returned 1 exit status
I don't konw hot to fix it....
Could somebody help me? I'll appreciate that.
Laurence