proc 질문 다시 올립니다.
글쓴이: cjy1126 / 작성시간: 수, 2003/04/02 - 1:50오후
proc proc.pc 를 하니까 proc.c proc.lis 2개의 파일이 가 생깁니다.
gcc -o proc proc.c 로 컴파일을 하니까
proc.c:215: redefinition of `struct sqlca' 가 나옵니다.
헤더에서 #include <sqlca.h>를 빼면 밑에 에러가 나오고요.
/tmp/cc4CPNLY.o: In function `main':
/tmp/cc4CPNLY.o(.text+0x203): undefined reference to `sqlcxt'
/tmp/cc4CPNLY.o(.text+0x2a3): undefined reference to `sqlcxt'
/tmp/cc4CPNLY.o(.text+0x33b): undefined reference to `sqlcxt'
/tmp/cc4CPNLY.o: In function `get_data':
/tmp/cc4CPNLY.o(.text+0x4b1): undefined reference to `sqlcxt'
collect2: ld returned 1 exit status
조언이나 답변 부탁드립니다.
밑에는 소스입니다.
#include <stdio.h>
#include <string.h>
#include <sqlca.h>
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR user_id[20];
VARCHAR passwd[20];
VARCHAR saddr[16];
EXEC SQL END DECLARE SECTION;
EXEC SQL INCLUDE SQLCA;
void get_data();
main()
{
printf("\n Enter User Id: ");
scanf("%s", user_id.arr);
printf("\n Enter Password: ");
scanf("%s", passwd.arr);
user_id.len = strlen(user_id.arr);
passwd.len = strlen(passwd.arr);
EXEC SQL CONNECT :user_id IDENTIFIED BY :passwd;
if(sqlca.sqlcode < 0)
{
printf("\n%s", sqlca.sqlerrm.sqlerrmc);
EXEC SQL ROLLBACK WORK RELEASE;
exit(1);
}
else
{
printf("\nConnect to Oracle.");
EXEC SQL COMMIT WORK RELEASE;
get_data();
}
exit(0);
}
void get_data()
{
EXEC SQL SELECT SADDR INTO : saddr FROM CLIENT;
printf("\n 차단된 주소");
printf("\n %s", saddr);
}Forums:


소스에서 #include <sqlca.h>와EXEC S
소스에서
#include <sqlca.h>와
EXEC SQL INCLUDE SQLCA;
는 같은 역할을 합니다. 즉 sqlca.h를 두번 포함하기 때문에 에러가 발생하는 것입니다.
둘 중에 하나만 없애시면 해결 됨 ^ ^;;
즐 프 하 세 요 ~~~
/tmp/cc4CPNLY.o: In function `main': /
/tmp/cc4CPNLY.o: In function `main':
/tmp/cc4CPNLY.o(.text+0x203): undefined reference to `sqlcxt'
/tmp/cc4CPNLY.o(.text+0x2a3): undefined reference to `sqlcxt'
/tmp/cc4CPNLY.o(.text+0x33b): undefined reference to `sqlcxt'
/tmp/cc4CPNLY.o: In function `get_data':
/tmp/cc4CPNLY.o(.text+0x4b1): undefined reference to `sqlcxt'
collect2: ld returned 1 exit status
이 에러메시지는
오라클 라이브러리 폴더의 libclntsh.so 파일을 링크 시킬 때 포함하시면 해결됩니다.
gcc -o prog prog.o libclntsh.so(절대경로로)
하시면됩니다.
정말 감사드립니다!!
새해복 많이 받으세요
-l 옵션을 쓰는게 맞겠죠?
사족) -lclntsh 으로 ^^* (왜냐하면 shared object라이브러리이니까요 )
========================================
* The truth will set you free.
댓글 달기