免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3690 | 回复: 1
打印 上一主题 下一主题

Linux平台下 OCCI 连接 Oracle数据库的链接错误 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-24 14:27 |只看该作者 |正序浏览
Linux平台下 OCCI 连接 Oracle数据库的链接错误

   本人在linux平台下使用eclipse做数据库的开发,在连接oracle数据库时出现了一个问题,希望各位linxu平台下开发高手给予指导。

由于我以前一直是在windows平台下做开发,所以对linux环境很是陌生。最开始的时候,我查看网上的资料,说是linux平台下使用occi连接oracle是比较好的选择,所以就使用了occi,但是刚开始碰到的问题跟我下面描述的问题基本是一样的,网上的兄弟们说那是因为老版的occi是用低版本的gcc编译器编译的,可能是因为不兼容导致,所以我昨天在oracle的官网下了一个最新的occi包,覆盖以后还是问题依旧,以下是安装包的自述文件

These files are required to build OCCI applications using the
gcc version 3.4.3 compiler on RedHat Linux (x86_64) AS 4.0.
The OCCI libraries shipped in the 10.2.0.3.0 release
are built with gcc 3.2.3 and are incompatible with gcc 3.4.3.
These support files are for the Oracle 10.2.0.3.0 release for
Linux X86_64. Since gcc binaries are compatible accross 3.4.3
and 4.0.1 versions, this patch can be applied for gcc 4.0.1
also.

Installation Instructions
-------------------------
1) Take a backup of the following files in the Oracle
   10.2.0.3.0 installation :-

    $ORACLE_HOME/lib/libocci10.a
    $ORACLE_HOME/lib/libocci.so.10.1
    $ORACLE_HOME/rdbms/public/occiCommon.h

   Preferably, these files should be backed up to
   $ORACLE_HOME/lib/gcc323

2) Copy the files from this archive to appropriate
   directories :-

    libocci10.a => $ORACLE_HOME/lib/
    libocci.so.10.1 => $ORACLE_HOME/lib
    occiCommon.h => $ORACLE_HOME/rdbms/public

3) Ensure that the gcc 3.4.3 compiler is setup and
   the default compiler to run(first in path). To
   revert back to gcc 3.2.3 compiler, restore the
   backed up OCCI files to their original
   directories.

Instant Client Installation
---------------------------
The OCCI dynamic library libocci.so.10.1 present in this
package can replace the default libocci.so.10.1 in the
Oracle 10g R2 Instant Client Basic package for deploying
OCCI applications.

Installing Patches
------------------
If any Oracle supplied patch install procedure regenerates
the client shared libraries, the newly generated libocci.so.10.1
in $ORACLE_HOME/lib will not be compatible with gcc 3.4.3. The
libocci.so.10.1 in this archive needs to be re-copied to
$ORACLE_HOME/lib.
覆盖以后所报的链接错误不一样,但总的来说问题是一样的,只是报错的未定义引用的函数名不一样

以下是我开发所用环境
eclipse3.3.1.1
linxu RedHat 4.5 x86_64
oracle 10g(10.1.0.2.0)
gcc version 3.4.6(3.4.3)在控制台中查看gcc版本是3.4.6,可是在eclipse的工程下,看见所include的却是3.4.3,我有点不明白。因为在eclipse中每建一个工程,编译器会自动include一些必须的文件


这是我eclipse使用oracle occi库所做的配置
/home/client/OraHome_1/rdbms/public   头文件
occi10                                库名
/home/client/OraHome_1/lib            库路径

#include "/home/client/OraHome_1/rdbms/public/occi.h"
using namespace oracle:cci;

int main(int argc, char* argv[])
{
        Environment *env;
        Connection  *conn;        
        env  = Environment::createEnvironment(Environment:EFAULT);
        conn = env->createConnection("usrname", "pwd", "db";
        ..............
        ..............
        return 0;
}


在eclipse下编译后,链接时报出如下错误:
'/usr/bin/ld: skipping incompatible /usr/lib/libm.so when searching for -lm
/usr/bin/ld: skipping incompatible /usr/lib/libm.a when searching for -lm
/usr/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
/usr/bin/ld: skipping incompatible /usr/lib/libc.a when searching for -lc
这些错误看起来可能是平台的问题,我的系统是64位,难道这些库是32位的吗?但是这个问题不影响我程序的运行,并不是问题的关键所在,随便写个其它的程序都报这个错,但是程序运行无误。应该算是一个警告吧

/home/client/OraHome_1/lib/libocci10.a(occiNumber.o)(.text+0x3285): In function `oracle:cci::Number::sin() const':: undefined reference to`lnxqtra'

/home/client/OraHome_1/lib/libocci10.a(occiNumber.o)(.text+0x3314): In function `oracle:cci::Number::cos() const':: undefined reference to `lnxqtra'
这些错误的意思是不是说:在libocci10的库中调用了其它的库,比如occiNumber,而这个库中又使用了一些未定义的引用???下面还有很多其它被间接调用的库

/home/client/OraHome_1/lib/libocci10.a(occiNumber.o)(.text+0x33ab): In function `oracle:cci::Number::tan() const':: undefined reference to `lnxqtra

/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x5b4): In function `oracle:cci::Environment::terminateEnvironment(oracle:cci::Environment*)':: undefined reference to `OCIHandleFree'

/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x60c): In function `oracle:cci::Environment::getXAEnvironment(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&':: undefined reference to `xaoEnv'

/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x621): In function `oracle:cci::Environment::getXAEnvironment(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&':: undefined reference to `xaoEnv'

/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x646): In function `oracle:cci::Environment::getXAEnvironment(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&':: undefined reference to `OCIHandleAlloc'

/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x670): In function `oracle:cci::Environment::getXAEnvironment(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&':: undefined reference to `OCIAttrGet'

.............................中间还有很多错误

/home/client/OraHome_1/lib/libocci10.a(occiEnvImpl.o)(.text+0x12ea): In function `oracle::occi::EnvironmentImpl::getXAConnection(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&':: undefined reference to `OCIPHeapAlloc'

/home/client/OraHome_1/lib/libocci10.a(occiEnvImpl.o)(.text+0x157f): In function `oracle::occi::EnvironmentImpl::getCacheSortedFlush() const':: undefined reference to `OCIAttrGet'

/home/client/OraHome_1/lib/libocci10.a(occiAnyDataImpl.o)(.text+0x427c): In function `oracle::occi::AnyDataImpl::getAsRef() const':: undefined reference to `OCIObjectNew'

/home/client/OraHome_1/lib/libocci10.a(occiAnyDataImpl.o)(.text+0x42a4): In function `oracle::occi::AnyDataImpl::getAsRef() const':: undefined reference to `OCIAnyDataGetType'

/home/client/OraHome_1/lib/libocci10.a(occiAnyDataImpl.o)(.text+0x42db): In function `oracle::occi::AnyDataImpl::getAsRef() const':: undefined reference to `OCIAnyDataAccess'

/home/client/OraHome_1/lib/libocci10.a(occiAnyDataImpl.o)(.text+0x4340): In function `oracle::occi::AnyDataImpl::getAsRef() const':: undefined reference to `OCIObjectFree'

/home/client/OraHome_1/lib/libocci10.a(occiAnyDataImpl.o)(.text+0x4404): In function `oracle::occi::AnyDataImpl::getType() const':: undefined reference to `OCIAnyDataGetType'

collect2: ld returned 1 exit status
`make: *** [AGM] Error 1   

这个问题我思索了两三天了,急的我团团转,但还是没有头绪,望各位开发高手不吝赐教,先谢谢了!

论坛徽章:
0
2 [报告]
发表于 2008-04-24 14:34 |只看该作者
int main(int argc, char* argv[])
{
        Environment *env;
        Connection  *conn;        
        env  = Environment::createEnvironment(Environment:EFAULT);
        conn = env->createConnection("usrname", "pwd", "db";
        ..............
        ..............
        return 0;
}

还有一点,在此段中,如果注释掉env  = Environment::createEnvironment(EnvironmentEFAULT);行,则链接不会报错,看来是occi的环境变量调用出了错,但是连接对象链接正常。
  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP