如果还不解决,我的老板就会把吊起来熏着吃了。
在Linux下写了一个Oracle的C++编程接口,其内部使用OCI,现在说一下其结构:
object.h
object.cpp
定义Object,CRuntimeClass类,当然还有支持动态信息的几组宏
已经编译成object.o
databaseinterface.h
databaseinterface.cpp
定义CDi类
这是一个纯虚拟类,用来进行封装具体的数据库接口。
已经编译成databaseinterface.o
oci.h
oci.cpp
定义COci类
此类从CDi类派生,是一个具体类,它封装了OCI,是用户能方便的使用OCI类操做数据库。
已经编译成oci.o
result.h
result.cpp
定义CResult类
这是一个虚拟类,用来派生出具体的RESULT类。
已经编译成result.o
ociresult.h
ociresult.cpp
定义COciResult类
这个类为用COci来操作数据库的RESULT
已经编译成ociresult.o
oracle.h
oracle.cpp
定义COracle类
一个具体的数据库类
已经编译成oracle.o
demo.cpp
演示程序
SouceCode :
#include "oracle.h"
#include "oci.h"
#include "ociresult.h"
main()
{
int charge;
COci oci; //定义操作数据库接口
COciResult* rs; //数据集接口
COracle conn(&oci,RUNTIME_CLASS(COciResult)); // bind
conn.Connect("MM","MM");
rs=(COciResult*)conn.Execute("select * from acct_item where serv_id="+CONVER(93183));
rs->Fetch();
rs->GetValue("charge",&charge);
std::cout<<charge;
}
成功编译后
用g++ -o demo demo.o 来连接,出现如下错误,请大家帮忙,应该怎么连接,谢谢
demo.o: In function `COci::~COci(void)':
demo.o(.text+0xc3f): undefined reference to `COci virtual table'
demo.o(.text+0xd51): undefined reference to `CDi::~CDi(void)'
demo.o: In function `COracle::COracle(CDi *, CRuntimeClass *)':
demo.o(.text+0x2097): undefined reference to `CObject::CObject(void)'
demo.o: In function `COci::COci(void)':
demo.o(.COci::gnu.linkonce.t.(void)+0x19): undefined reference to `COci virtual
table'
demo.o(.COci::gnu.linkonce.t.(void)+0x102): undefined reference to `CDi::~CDi(vo
id)'
demo.o: In function `CResult type_info function':
demo.o(.gnu.linkonce.t.__tf7CResult+0x10): undefined reference to `CObject type_
info function'
demo.o(.gnu.linkonce.t.__tf7CResult+0x18): undefined reference to `CObject type_
info node'
demo.o: In function `COracle::~COracle(void)':
demo.o(.gnu.linkonce.t._._7COracle+0x1c): undefined reference to `CObject::~CObj
ect(void)'
demo.o: In function `COracle type_info function':
demo.o(.gnu.linkonce.t.__tf7COracle+0x10): undefined reference to `CObject type_
info function'
demo.o(.gnu.linkonce.t.__tf7COracle+0x18): undefined reference to `CObject type_
info node'
demo.o: In function `CDi::CDi(void)':
demo.o(.CDi::gnu.linkonce.t.(void)+0xf): undefined reference to `CObject::CObjec
t(void)'
demo.o(.CDi::gnu.linkonce.t.(void)+0x18): undefined reference to `CDi virtual ta
ble'
demo.o: In function `CResult::~CResult(void)':
demo.o(.gnu.linkonce.t._._7CResult+0x1c): undefined reference to `CObject::~CObj
ect(void)'
demo.o: In function `CResult::CResult(void)':
demo.o(.CResult::gnu.linkonce.t.(void)+0xf): undefined reference to `CObject::CO
bject(void)'
collect2: ld returned 1 exit status