Chinaunix

标题: 新手请教:HP UNIX 中C++程序无法调用动态库的问题 [打印本页]

作者: newman_xpb    时间: 2003-09-13 12:29
标题: 新手请教:HP UNIX 中C++程序无法调用动态库的问题
我写了一个C++程序,需要调用两个自己写的动态库。
库libdbopr.sl是用于访问数据库的函数库,
libdbclass.sl 封装了一些C++类,这些类调用libdbopr.sl中的函数,
程序test1.cpp中使用libdbclass.sl 中的C++类。

库libdbopr.sl的编译命令为:
ar -rs  libdbopr.sl ./dbopr.o        (dbopr.o由.pc文件通过proc和cc编译得到)

库libdbclass.sl的编译命令为:
aCC  ./dbclass.cpp -o ./dbclass.o  -L. -ldbopr
ar -rs  ./libdbclass.sl ./dbclass.o

以上两个库的编译没有报错。而且用C程序调用数据库操作库  libdbopr.sl 正确。

但是test1.cpp的编译报错。test1.cpp的编译命令为:
aCC  ./test1.cpp -o ./test1 -L. -ldbclass -ldbopr
错误信息:
/usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (test1.o) was detect.
/usr/ccs/bin/ld: ./libmbdbopr.sl: Not a valid library (invalid magic number). P.
*** Error exit code 1

改用如下编译命令:  
aCC  ./test1.cpp -o ./test1 -L. -ldbclass
错误信息变为:
Error 419: \"./test1.cpp\", line 19 # \'CTable1\' is used as a type, but has
    not been defined as a type.
            CTable1   Object;
            ^^^^^^^^^^^^^
Error 186: \"./test1.cpp\", line 31 # Left side of \'.\' requires a class object;
    type found was \'int\'.
            Object.InsRecord(&record);
            ^^^^^^
Error 328: \"./test1.cpp\", line 67 # Function \'DBLinkOperate\' has not been
    defined yet; cannot call.
            iReturnCode=DBLinkOperate(DB_COMMIT);
                        ^^^^^^^^^^^^^
类CTable1封装在libdbclass.sl 中,函数DBLinkOperate封装在库libdbopr.sl 中。

为什么我在test1.cpp中无法调用这些库中的东西呢?


谢谢各位大虾!!!!




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2