- 论坛徽章:
- 0
|
先谢谢了。
错误如下:
$ proc iname=games.pc oname=games.c
Pro*C/C++: Release 8.1.5.0.0 - Production on Thu May 20 16:01:03 2004
(c) Copyright 1999 Oracle Corporation. All rights reserved.
System default option values taken from: /app/oracle/product/8.1.5/precomp/admin/pcscfg.cfg
$ cc -o games games.c
Undefined first referenced
symbol in file
sqlcxt games.o
UX:ld: ERROR: games: fatal error: Symbol referencing errors. No output written to games
$
代码如下(只是做了数据库的连接):
#include <stdio.h>;
#include <string.h>;
#include <stdlib.h>;
#include "/app/oracle/product/8.1.5/precomp/public/oraca.h"
#include "/app/oracle/product/8.1.5/precomp/public/sqlca.h"
EXEC SQL INCLUDE SQLCA;
#define UNAME_LEN 20
#define PWD_LEN 20
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR username[UNAME_LEN];
VARCHAR password[PWD_LEN];
EXEC SQL END DECLARE SECTION;
void sql_error(char *msg)
{
EXEC SQL WHENEVER SQLERROR CONTINUE;
printf("oracle error:%s\n", msg);
EXEC SQL ROLLBACK WORK RELEASE;
exit(-1);
}
void main()
{
strncpy((char *) username.arr, "games", UNAME_LEN);
username.len = (unsigned short) strlen((char *)username.arr);
strncpy((char *) password.arr, "zhangsh", PWD_LEN);
password.len = (unsigned short) strlen((char *)password.arr);
EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--\n" ;
EXEC SQL CONNECT :username IDENTIFIED BY :password;
EXEC SQL COMMIT RELEASE;
exit(0);
} |
|