大家好,小弟在新公司改一个程序,这个程序用到了OCI函数,其中有一段代码如下
#ifdef ORACLE8
status = OCIStmtExecute(svchp,stmthp,errhp,(ub4)0, (ub4)0,(CONST OCISnapshot *)
NULL,(OCISnapshot *)NULL,(ub4)OCI_SCROLLABLE_CURSOR);
#endif
#ifdef ORACLE9
status = OCIStmtExecute(svchp,stmthp,errhp,(ub4)0, (ub4)0,(CONST OCISnapshot *)
NULL,(OCISnapshot *)NULL,(ub4)OCI_STMT_SCROLLABLE_READONLY);
#endif
这个程序支持ORACLE8和ORACLE9,头文件的宏定义 #define ORACLE9 0
这个程序编译出现以下问题,用的是makefile,操作系统位AIX5.1,数据库为ORACLE9
 /usr/vacpp/bin/xlc  -c ../public/public.c -o ../public/public.o
        test -d ./bin||mkdir bin
        /usr/vacpp/bin/xlc  -c -o src/extract.o -I /oracle/rdbms/demo -I /oracle/rdbms/public -I /oracle/plsql/public -I /oracle/network/public -I /oracle/precomp/public src/extract.c  
"src/extract.c", line 971.95: 1506-045 (S) Undeclared identifier OCI_STMT_SCROLLABLE_READONLY.
make: 1254-004 The error code from the last command is 1.
我把定义改成#define ORACLE8 0
编译,又出现如下问题,把status = OCIStmtExecute(svchp,stmthp,errhp,(ub4)0, (ub4)0,(CONST OCISnapshot *)
NULL,(OCISnapshot *)NULL,(ub4)OCI_STMT_SCROLLABLE_READONLY);中最好一个参数OCI_STMT_SCROLLABLE_READONLY改成其他,如OCI_DEFAULT,也会出现以下编译问题:
 /usr/vacpp/bin/xlc  -c ../public/public.c -o ../public/public.o
        test -d ./bin||mkdir bin
        /usr/vacpp/bin/xlc  -c -o src/extract.o -I /oracle/rdbms/demo -I /oracle/rdbms/public -I /oracle/plsql/public -I /oracle/network/public -I /oracle/precomp/public src/extract.c  
        /usr/vacpp/bin/xlc  -o bin/e_extract -L/oracle/lib32/ -L/oracle/rdbms/lib32/ -R/disk0/o9i/app/products/oracle/9.0.2/lib32 -laio  -lposix4 -lkstat -lm  -lthread -lclntsh `cat /oracle/lib/ldflags`   `cat /oracle/lib/sysliblist`  src/extract.o ../public/public.o
ld: 0706-027 The -R /disk0/o9i/app/products/oracle/9.0.2/lib32 flag is ignored.
ld: 0706-006 Cannot find or open library file: -l aio
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l posix4
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l kstat
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l thread
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l clntsh
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l nbeq8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l nhost8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l n8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l ncrypt8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l nidx8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l n8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l ncrypt8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l nus8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l n8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l ncrypt8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l nk58
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l n8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l ncrypt8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l nldap8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l ldapclnt8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l nsslb8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l n8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l ncrypt8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l n8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l ncrypt8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l noname8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l n8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l ncrypt8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l nrad8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l n8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l ncrypt8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l n8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l ncrypt8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l nsid8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l n8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l ncrypt8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l ntcp8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l ntcps8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l nsslb8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l nent8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l ntcp8
        ld:open(): A file or directory in the path name does not exist.
ld: 0706-006 Cannot find or open library file: -l ntns8
        ld:open(): A file or directory in the path name does not exist.
make: 1254-004 The error code from the last command is 255.请问这是什么问题?如何解决?谢谢

解决方案 »

  1.   

    要检查ORACLE8 和ORACLE9是否定义,这里要和定义的名字一致
      

  2.   

    你用了别人的Makefile的模版,但和你的环境不一致,所以导致连接不上。
    抄没有关系,建议你要抄懂。
    OCI从9开始只需要 -lclntsh 这个连接开关,有的平台要加 -laio 开关
    建议你自己写Makefile,容易定位错误。-----------------------------------------------------------
    《征服C/C++企业软件开发核心技术》
    主题词 unix/linux 多线程 网络通讯 数据库 内存排错和性能分析
    http://www.khp.com.cn/books/detail.asp?bookid=1707