使用Occi连接Oracle数据库的配置

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u012372584/article/details/80095004

1、首先注意occi库是64位还是32位,一定要和IDE的环境匹配好,同时和vs的版本也要匹配!

2、Oracle C++ Call Interface - Downloads的下载地址:Oracle C++ Call Interface下载地址

3、我是直接安装了 64位 Oracle 11g,安装完后就有配置需要的头文件和库文件,我的目录如下:

头文件目录:H:\app\admin\product\11.2.0\dbhome_1\OCI\include

库文件目录:H:\app\admin\product\11.2.0\dbhome_1\OCI\lib\MSVC

另外需要包含3个附加依赖项:oci.lib、ociw32.lib、oraocci11.lib

4、经过配置发现Debug下是没问题的,Release下还存在一些问题(没有解决)。暂且先在Debug下操作数据库。等有了Oracle的账号,再下载 2 中的库来配置一下。 


展开阅读全文

Linux平台下 OCCI 连接 Oracle数据库的链接错误

04-24

Linux平台下 OCCI 连接 Oracle数据库的链接错误 rnrn 本人在linux平台下使用eclipse做数据库的开发,在连接oracle数据库时出现了一个问题,希望各位linxu平台下开发高手给予指导。rnrn由于我以前一直是在windows平台下做开发,所以对linux环境很是陌生。最开始的时候,我查看网上的资料,说是linux平台下使用occi连接oracle是比较好的选择,所以就使用了occi,但是刚开始碰到的问题跟我下面描述的问题基本是一样的,网上的兄弟们说那是因为老版的occi是用低版本的gcc编译器编译的,可能是因为不兼容导致,所以我昨天在oracle的官网下了一个最新的occi包,覆盖以后还是问题依旧,以下是安装包的自述文件rnrnThese files are required to build OCCI applications using therngcc version 3.4.3 compiler on RedHat Linux (x86_64) AS 4.0.rnThe OCCI libraries shipped in the 10.2.0.3.0 releasernare built with gcc 3.2.3 and are incompatible with gcc 3.4.3. rnThese support files are for the Oracle 10.2.0.3.0 release for rnLinux X86_64. Since gcc binaries are compatible accross 3.4.3rnand 4.0.1 versions, this patch can be applied for gcc 4.0.1 rnalso.rnrnInstallation Instructionsrn-------------------------rn1) Take a backup of the following files in the Oracle rn 10.2.0.3.0 installation :-rnrn $ORACLE_HOME/lib/libocci10.arn $ORACLE_HOME/lib/libocci.so.10.1rn $ORACLE_HOME/rdbms/public/occiCommon.hrnrn Preferably, these files should be backed up to rn $ORACLE_HOME/lib/gcc323rnrn2) Copy the files from this archive to appropriate rn directories :-rnrn libocci10.a => $ORACLE_HOME/lib/rn libocci.so.10.1 => $ORACLE_HOME/librn occiCommon.h => $ORACLE_HOME/rdbms/publicrnrn3) Ensure that the gcc 3.4.3 compiler is setup andrn the default compiler to run(first in path). Torn revert back to gcc 3.2.3 compiler, restore the rn backed up OCCI files to their original rn directories.rnrnInstant Client Installationrn---------------------------rnThe OCCI dynamic library libocci.so.10.1 present in thisrnpackage can replace the default libocci.so.10.1 in the rnOracle 10g R2 Instant Client Basic package for deploying rnOCCI applications.rnrnInstalling Patchesrn------------------rnIf any Oracle supplied patch install procedure regeneratesrnthe client shared libraries, the newly generated libocci.so.10.1rnin $ORACLE_HOME/lib will not be compatible with gcc 3.4.3. Thernlibocci.so.10.1 in this archive needs to be re-copied to rn$ORACLE_HOME/lib. rn覆盖以后所报的链接错误不一样,但总的来说问题是一样的,只是报错的未定义引用的函数名不一样rnrn以下是我开发所用环境rneclipse3.3.1.1rnlinxu RedHat 4.5 x86_64rnoracle 10g(10.1.0.2.0)rngcc version 3.4.6(3.4.3)在控制台中查看gcc版本是3.4.6,可是在eclipse的工程下,看见所include的却是3.4.3,我有点不明白。因为在eclipse中每建一个工程,编译器会自动include一些必须的文件rnrnrn这是我eclipse使用oracle occi库所做的配置rn/home/client/OraHome_1/rdbms/public 头文件rnocci10 库名rn/home/client/OraHome_1/lib 库路径rnrn#include "/home/client/OraHome_1/rdbms/public/occi.h"rnusing namespace oracle::occi;rnrnint main(int argc, char* argv[])rnrn Environment *env;rn Connection *conn; rn env = Environment::createEnvironment(Environment::DEFAULT);rn conn = env->createConnection("usrname", "pwd", "db");rn ..............rn ..............rn return 0;rnrnrnrn在eclipse下编译后,链接时报出如下错误:rn'/usr/bin/ld: skipping incompatible /usr/lib/libm.so when searching for -lmrn/usr/bin/ld: skipping incompatible /usr/lib/libm.a when searching for -lmrn/usr/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc rn/usr/bin/ld: skipping incompatible /usr/lib/libc.a when searching for -lcrn这些错误看起来可能是平台的问题,我的系统是64位,难道这些库是32位的吗?但是这个问题不影响我程序的运行,并不是问题的关键所在,随便写个其它的程序都报这个错,但是程序运行无误。应该算是一个警告吧rnrn/home/client/OraHome_1/lib/libocci10.a(occiNumber.o)(.text+0x3285): In function `oracle::occi::Number::sin() const':: undefined reference to`lnxqtra'rnrn /home/client/OraHome_1/lib/libocci10.a(occiNumber.o)(.text+0x3314): In function `oracle::occi::Number::cos() const':: undefined reference to `lnxqtra'rn这些错误的意思是不是说:在libocci10的库中调用了其它的库,比如occiNumber,而这个库中又使用了一些未定义的引用???下面还有很多其它被间接调用的库rnrn/home/client/OraHome_1/lib/libocci10.a(occiNumber.o)(.text+0x33ab): In function `oracle::occi::Number::tan() const':: undefined reference to `lnxqtrarnrn/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x5b4): In function `oracle::occi::Environment::terminateEnvironment(oracle::occi::Environment*)':: undefined reference to `OCIHandleFree'rnrn/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x60c): In function `oracle::occi::Environment::getXAEnvironment(std::basic_string, std::allocator > const&)':: undefined reference to `xaoEnv'rnrn/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x621): In function `oracle::occi::Environment::getXAEnvironment(std::basic_string, std::allocator > const&)':: undefined reference to `xaoEnv'rnrn/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x646): In function `oracle::occi::Environment::getXAEnvironment(std::basic_string, std::allocator > const&)':: undefined reference to `OCIHandleAlloc'rnrn/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x670): In function `oracle::occi::Environment::getXAEnvironment(std::basic_string, std::allocator > const&)':: undefined reference to `OCIAttrGet'rnrn.............................中间还有很多错误rnrn/home/client/OraHome_1/lib/libocci10.a(occiEnvImpl.o)(.text+0x12ea): In function `oracle::occi::EnvironmentImpl::getXAConnection(std::basic_string, std::allocator > const&)':: undefined reference to `OCIPHeapAlloc'rnrn/home/client/OraHome_1/lib/libocci10.a(occiEnvImpl.o)(.text+0x157f): In function `oracle::occi::EnvironmentImpl::getCacheSortedFlush() const':: undefined reference to `OCIAttrGet'rnrn/home/client/OraHome_1/lib/libocci10.a(occiAnyDataImpl.o)(.text+0x427c): In function `oracle::occi::AnyDataImpl::getAsRef() const':: undefined reference to `OCIObjectNew'rnrn/home/client/OraHome_1/lib/libocci10.a(occiAnyDataImpl.o)(.text+0x42a4): In function `oracle::occi::AnyDataImpl::getAsRef() const':: undefined reference to `OCIAnyDataGetType'rnrn/home/client/OraHome_1/lib/libocci10.a(occiAnyDataImpl.o)(.text+0x42db): In function `oracle::occi::AnyDataImpl::getAsRef() const':: undefined reference to `OCIAnyDataAccess'rnrn/home/client/OraHome_1/lib/libocci10.a(occiAnyDataImpl.o)(.text+0x4340): In function `oracle::occi::AnyDataImpl::getAsRef() const':: undefined reference to `OCIObjectFree'rnrn/home/client/OraHome_1/lib/libocci10.a(occiAnyDataImpl.o)(.text+0x4404): In function `oracle::occi::AnyDataImpl::getType() const':: undefined reference to `OCIAnyDataGetType'rnrncollect2: ld returned 1 exit statusrn`make: *** [AGM] Error 1 rnrn这个问题我思索了两三天了,急的我团团转,但还是没有头绪,望各位开发高手不吝赐教,先谢谢了!rnrnrn 论坛

没有更多推荐了,返回首页