当前位置: 技术问答>linux和unix
Linux平台下 OCCI 连接 Oracle数据库的链接错误
来源: 互联网 发布时间:2016-03-17
本文导语: Linux平台下 OCCI 连接 Oracle数据库的链接错误 本人在linux平台下使用eclipse做数据库的开发,在连接oracle数据库时出现了一个问题,希望各位linxu平台下开发高手给予指导。 由于我以...
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::occi;
int main(int argc, char* argv[])
{
Environment *env;
Connection *conn;
env = Environment::createEnvironment(Environment::DEFAULT);
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::occi::Number::sin() const':: undefined reference to`lnxqtra'
/home/client/OraHome_1/lib/libocci10.a(occiNumber.o)(.text+0x3314): In function `oracle::occi::Number::cos() const':: undefined reference to `lnxqtra'
这些错误的意思是不是说:在libocci10的库中调用了其它的库,比如occiNumber,而这个库中又使用了一些未定义的引用???下面还有很多其它被间接调用的库
/home/client/OraHome_1/lib/libocci10.a(occiNumber.o)(.text+0x33ab): In function `oracle::occi::Number::tan() const':: undefined reference to `lnxqtra
/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x5b4): In function `oracle::occi::Environment::terminateEnvironment(oracle::occi::Environment*)':: undefined reference to `OCIHandleFree'
/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x60c): In function `oracle::occi::Environment::getXAEnvironment(std::basic_string const&)':: undefined reference to `xaoEnv'
/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x621): In function `oracle::occi::Environment::getXAEnvironment(std::basic_string const&)':: undefined reference to `xaoEnv'
/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x646): In function `oracle::occi::Environment::getXAEnvironment(std::basic_string const&)':: undefined reference to `OCIHandleAlloc'
/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x670): In function `oracle::occi::Environment::getXAEnvironment(std::basic_string 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 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
这个问题我思索了两三天了,急的我团团转,但还是没有头绪,望各位开发高手不吝赐教,先谢谢了!
本人在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::occi;
int main(int argc, char* argv[])
{
Environment *env;
Connection *conn;
env = Environment::createEnvironment(Environment::DEFAULT);
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::occi::Number::sin() const':: undefined reference to`lnxqtra'
/home/client/OraHome_1/lib/libocci10.a(occiNumber.o)(.text+0x3314): In function `oracle::occi::Number::cos() const':: undefined reference to `lnxqtra'
这些错误的意思是不是说:在libocci10的库中调用了其它的库,比如occiNumber,而这个库中又使用了一些未定义的引用???下面还有很多其它被间接调用的库
/home/client/OraHome_1/lib/libocci10.a(occiNumber.o)(.text+0x33ab): In function `oracle::occi::Number::tan() const':: undefined reference to `lnxqtra
/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x5b4): In function `oracle::occi::Environment::terminateEnvironment(oracle::occi::Environment*)':: undefined reference to `OCIHandleFree'
/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x60c): In function `oracle::occi::Environment::getXAEnvironment(std::basic_string const&)':: undefined reference to `xaoEnv'
/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x621): In function `oracle::occi::Environment::getXAEnvironment(std::basic_string const&)':: undefined reference to `xaoEnv'
/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x646): In function `oracle::occi::Environment::getXAEnvironment(std::basic_string const&)':: undefined reference to `OCIHandleAlloc'
/home/client/OraHome_1/lib/libocci10.a(occiEnv.o)(.text+0x670): In function `oracle::occi::Environment::getXAEnvironment(std::basic_string 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 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
这个问题我思索了两三天了,急的我团团转,但还是没有头绪,望各位开发高手不吝赐教,先谢谢了!
|
打10.2.0.4的补丁,里面包含occi最新的补丁
贴Makefile出来,
另外,把gcc -v 的信息打出来。
我用rhel 5 x86_64 + oracle 10.2.0.4 的occi,连接时使用occi343的库,没有任何问题。
贴Makefile出来,
另外,把gcc -v 的信息打出来。
我用rhel 5 x86_64 + oracle 10.2.0.4 的occi,连接时使用occi343的库,没有任何问题。