- 论坛徽章:
- 0
|
环境是 LinuxAS4
gcc 版本 : 3.4.4
occi版本: occi_gcc343_102030.tar.gz
很简单的一个程序[occi10.cpp],如下:
#include <string>
#include <iostream>
#include <occi.h>
using namespace oracle: cci;
using namespace std;
int main(int argc, char* argv[])
{
printf("Connect to Oracle\n" ;
string sUser = "USER";
string sPassword = " ASSWORD";
string sDB = "DATABASE";
Environment *env = Environment::createEnvironment (Environment: EFAULT);
Connection *conn = env->createConnection (sUser, sPassword, sDB);
Statement * stmt = conn->createStatement("SELECT DATA1, DATA2 FROM TEST_TABLE" ;
ResultSet *rset = stmt->executeQuery();
while (rset->next())
{
cout << "DATA1:" << rset->getString (1) ;
cout << "DATA2:" << rset->getString (2) << endl;
}
stmt->closeResultSet (rset);
conn->terminateStatement (stmt);
env->terminateConnection (conn);
Environment::terminateEnvironment (env);
return true;
}
编译的命令如下:
g++ -L /usr/lib/oracle/10.2.0.3/client/lib -I /usr/include/oracle/10.2.0.3/client/ -o occi10.o -c occi10.cpp
然后:
g++ -o occi10 occi10.o
之后产生错误:
occi10.o(.text+0x23f): In function `main':
: undefined reference to `oracle: cci::Environment::createEnvironment(oracle: cci::Environment::Mode, void*, void* (*)(void*, unsigned int), void* (*)(void*, void*, unsigned int), void (*)(void*, void*))'
occi10.o(.text+0x51e): In function `main':
: undefined reference to `oracle: cci::Environment::terminateEnvironment(oracle: cci::Environment*)'
collect2: ld returned 1 exit status
期望高手指点,谢谢! |
|