| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 529 人关注过本帖
标题:请教一个pro*c程序的问题,编译成可执行程序报错
只看楼主 加入收藏
khaz
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:130
专家分:188
注 册:2011-4-21
结帖率:77.78%
收藏
 问题点数:0 回复次数:1 
请教一个pro*c程序的问题,编译成可执行程序报错
[hwt@localhost proc]$ cat 1.pc
程序代码:
#include<stdio.h>
EXEC SQL BEGIN DECLARE SECTION;
char username[20];
char password[20];
char last_name[25];
EXEC SQL END DECLARE SECTION;
EXEC SQL INCLUDE sqlca;
main()
{
   EXEC SQL WHENEVER SQLERROR DO sqlerror();
   strcpy(username,"viewdb");
   strcpy(password, "viewdb");
   EXEC SQL CONNECT:username IDENTIFIED BY:password;
   EXEC SQL select "1234" into :last_name from dual ;
   printf("\nID=2,last_name=%s\n" , last_name);
}



[hwt@localhost proc]$ proc iname=1.pc oname=1.c parse=full

Pro*C/C++: Release 10.2.0.1.0 - Production on 星期六 4月 16 05:31:04 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

系统默认选项值取自于:  /opt/app/oracle/product/10.2.0/db_1/precomp/admin/pcscfg.cfg

[hwt@localhost proc]$ cc -o 1 1.c
/tmp/ccAoBhfX.o(.text+0x1f9): In function `main':
: undefined reference to `sqlcxt'
/tmp/ccAoBhfX.o(.text+0x20a): In function `main':
: undefined reference to `sqlerror'
/tmp/ccAoBhfX.o(.text+0x37b): In function `main':
: undefined reference to `sqlcxt'
/tmp/ccAoBhfX.o(.text+0x38c): In function `main':
: undefined reference to `sqlerror'
collect2: ld returned 1 exit status
[hwt@localhost proc]$ env
HOSTNAME=localhost
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
NLS_LANG=Simplified Chinese_CHINA.ZHS16GBK
SSH_CLIENT=::ffff:192.168.187.1 49355 22
ORACLE_DOC=/opt/app/oracle/product/10.2.0/db_1/doc
QTDIR=/usr/lib/qt-3.3
SSH_TTY=/dev/pts/0
USER=hwt
COBCPY=:/cobinclude
LD_LIBRARY_PATH=/lib:/opt/app/oracle/product/10.2.0/db_1/lib:/opt/app/oracle/product/10.2.0/db_1/ctx/lib:/opt/app/oracle/product/10.2.0/db_1/jdbc/lib
LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
ORACLE_SID=testdb
ORACLE_BASE=/opt/app/oracle
LIBPATH=/lib:
MAIL=/var/spool/mail/hwt
PATH=/bin:/usr/lib/jdk/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/hwt/bin:/opt/app/oracle/product/10.2.0/db_1/bin:/home/hwt/bin
INPUTRC=/etc/inputrc
PWD=/home/hwt/proc
JAVA_HOME=/usr/lib/jdk
COBOPT=-C ANS85 -C ALIGN=8 -C NOIBMCOMP -C TRUNC=ANSI -C OSEXT=cbl
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
SHLVL=1
HOME=/home/hwt
LANGUAGE=zh_CN.GB18030:zh_CN.GB2312:zh_CN
LOGNAME=hwt
CLASSPATH=/opt/app/oracle/product/10.2.0/db_1/jre:/opt/app/oracle/product/10.2.0/db_1/JRE:/opt/app/oracle/product/10.2.0/db_1/jlib:/opt/app/oracle/product/10.2.0/db_1/rdbms/jlib:/opt/app/oracle/product/10.2.0/db_1/jdbc/lib/classes12.jar:/opt/app/oracle/product/10.2.0/db_1/jdbc/lib/nls_charset12.jar
SSH_CONNECTION=::ffff:192.168.187.1 49355 ::ffff:192.168.187.4 22
LESSOPEN=|/usr/bin/lesspipe.sh %s
SHLIB_PATH=/lib:
ORA_NLS33=/opt/app/oracle/product/10.2.0/db_1/ocommon/nls/admin/data
ORACLE_HOME=/opt/app/oracle/product/10.2.0/db_1
G_BROKEN_FILENAMES=1
_=/bin/env
OLDPWD=/home/hwt
搜索更多相关主题的帖子: color c程序 
2011-07-12 13:11
khaz
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:130
专家分:188
注 册:2011-4-21
收藏
得分:0 
自己解决了:
程序代码:
#include<stdio.h>
#include<sqlca.h>

int main()
{
EXEC SQL BEGIN DECLARE SECTION;
char username[20];
char password[20];
char last_name[25];
EXEC SQL END DECLARE SECTION;

   strcpy(username,"viewdb");
   strcpy(password, "viewdb");
   EXEC SQL CONNECT:username IDENTIFIED BY:password;
   EXEC SQL select 1234 into :last_name from dual ;
   printf("\nlast_name=%s\n" , last_name);
}
[hwt@localhost proc]$ cat makefile
1: 1.c
        cc -I${ORACLE_HOME}/precomp/public 1.c -o 1 -L${ORACLE_HOME}/lib -lclntsh
1.c: 1.pc
        proc iname=1.pc oname=1.c
[hwt@localhost proc]$ make
proc iname=1.pc oname=1.c

Pro*C/C++: Release 10.2.0.1.0 - Production on 星期六 4月 16 10:18:13 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

系统默认选项值取自于:  /opt/app/oracle/product/10.2.0/db_1/precomp/admin/pcscfg.cfg

cc -I/opt/app/oracle/product/10.2.0/db_1/precomp/public 1.c -o 1 -L/opt/app/oracle/product/10.2.0/db_1/lib -lclntsh
[hwt@localhost proc]$ ./1

last_name=1234
2011-07-12 20:09
快速回复:请教一个pro*c程序的问题,编译成可执行程序报错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017325 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved