occi linux编译环境的问题
大家好最近碰到了 occi编译环境的问题。
Redhat Linux9
装的是 Instant Client Downloads for Linux x86
Version 10.2.0.3
Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications
Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications
下载的网页地址是
http://www.oracle.com/technology ... docs/linuxsoft.html
设置的环境变量是
export ORACLE_BASE=/usr/lib/oracle/10.2.0.3/
export ORACLE_HOME=$ORACLE_BASE/client
export LD_LIBRARY_PATH=$LD_LIBRARY_PATHORACLE_HOME/lib
export PATH=$PATHORACLE_HOME/bin
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
export NLS_DATE_FORMAT="yyyy-mm-dd hh24:mi:ss"
安装SDK后头文件放的目录是/usr/include/oracle/10.2.0.3/client
另外 我还安装了g++ 3.4.3
方法是从网上找的
# cp gcc-3.4.3.tar.gz /usr/src
# cd /usr/src
# tar zxvf gcc-3.4.3.tar.gz
# cd gcc-3.4.3
# ./configure --prefix=/usr/local/src/gcc-3.4.3 --enable-threads=posix --disable-checking --enable--long-long --host=i386-redhat-linux --with-system-zlib --enable-languages=c,c++
# make
# make install
这样就将 gcc 3.4.3 安装到 /usr/local/src/gcc-3.4.3 目录下了。
为了和原系统中的gcc共存,可作如下符号链接:
# cd /usr/bin
# ln -s /usr/local/src/gcc-3.4.3/bin/gcc gcc343
# ln -s /usr/local/src/gcc-3.4.3/bin/g++ g++343
最后需设置库的路径到环境变量中。修改 /etc/profile 文件,在尾部增加:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/src/gcc-3.4.3/lib
然后写了个简单的例子
#include <iostream>
#include <occi.h>
using namespace oracle:cci;
using namespace std;
int main()
{
Environment *env;
Connection *conn;
Statement *stmt;
env = Environment::createEnvironment (Environment::OBJECT);
conn = env->createConnection ("ren_gzhu", "gzhu", "TRB"
cout<<"connect success"<<endl;
env->terminateConnection (conn);
Environment::terminateEnvironment (env);
cout<<"connect close"<<endl;
return 1;
}
然后从oracle官网上下载了
occi_gcc343_102030.tar.gz 把里边的
libocci10.a
libocci.so.10.1
放入 ORACLE_HOME/lib 其中原来目录下只有libocci.so.10.1 只替换了他一个。
编译命令是
g++343 -I/usr/include/oracle/10.2.0.3/client -g occitest.cpp -o occitese
报错是:
[root@xujing code]# g++343 -I/usr/include/oracle/10.2.0.3/client -g occitest.cpp -o occites
/tmp/ccl7DltA.o(.text+0x12a): In function `main':
/home/xujing/code/occitest.cpp:12: undefined reference to `oracle:cci::Environment::createEnvironment(oracle:cci::Environment::Mode, void*, void* (*)(void*, unsigned int), void* (*)(void*, void*, unsigned int), void (*)(void*, void*))'
/tmp/ccl7DltA.o(.text+0x317):/home/xujing/code/occitest.cpp:16: undefined reference to `oracle:cci::Environment::terminateEnvironment(oracle:cci::Environment*)'
collect2: ld returned 1 exit status
我还测试了下 [root@xujing lib]# ls
gcc343lib libclntsh.so.10.1 libocci10.a libocci.so.10.1 libocijdbc10.so
libclntsh.so libnnz10.so libocci.so libociei.so ojdbc14.jar
[root@xujing lib]# ldd libocci.so
ldd: warning: you do not have execution permission for `./libocci.so'
libstdc++.so.6 => not found
libm.so.6 => /lib/tls/libm.so.6 (0x400d7000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x400f9000)
libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
[root@xujing lib]# ldd libocci.so.10.1
ldd: warning: you do not have execution permission for `./libocci.so.10.1'
libstdc++.so.6 => not found
libm.so.6 => /lib/tls/libm.so.6 (0x400d7000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x400f9000)
libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
[root@xujing lib]# ldd libocci10.a
ldd: warning: you do not have execution permission for `./libocci10.a'
not a dynamic executable
[root@xujing lib]# ldd libclntsh.so
ldd: warning: you do not have execution permission for `./libclntsh.so'
libnnz10.so => not found
libdl.so.2 => /lib/libdl.so.2 (0x40df6000)
libm.so.6 => /lib/tls/libm.so.6 (0x40df9000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x40e1b000)
libnsl.so.1 => /lib/libnsl.so.1 (0x40e28000)
libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
[root@xujing lib]# ldd libnnz10.so
ldd: warning: you do not have execution permission for `./libnnz10.so'
libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
[root@xujing lib]# ldd libclntsh.so.10.1
ldd: warning: you do not have execution permission for `./libclntsh.so.10.1'
libnnz10.so => not found
libdl.so.2 => /lib/libdl.so.2 (0x40df6000)
libm.so.6 => /lib/tls/libm.so.6 (0x40df9000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x40e1b000)
libnsl.so.1 => /lib/libnsl.so.1 (0x40e29000)
libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
[root@xujing lib]#
我已经被折磨了一个多星期了,死的心都有了,希望能好心人帮忙解决,小弟跪谢了!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
跪求高手指点呀 顶上去