Home  >  Article  >  Database  >  在LINUX下 编译ORACLE OCCI接口应用程序

在LINUX下 编译ORACLE OCCI接口应用程序

WBOY
WBOYOriginal
2016-06-07 15:50:341062browse

主要分两个平台来说 1 在安装了ORACLE 服务器上 配置环境 [ba@nod1-ba lib]$ cat ~/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PAT

主要分两个平台来说

1 在安装了ORACLE 服务器上

 

 配置环境

[ba@nod1-ba lib]$ cat ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

export ORACLE_BASE=/oracle
export ORACLE_HOME=/oracle/rac
export CRS_HOME=/oracle/crs
export ORACLE_SID=esunba1
export PATH=$ORACLE_BASE/OPatch:$ORACLE_HOME/bin:$CRS_HOME/bin:$PATH:/sbin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH

export LC_ALL='zh_CN'
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
export NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SSXFF'
export NLS_LANG='SIMPLIFIED CHINESE_CHINA.ZHS16GBK'

 

然后编译自带的列子

OCCI接口编译
g++ occidml.cpp -I$ORACLE_HOME/rdbms/public -L$ORACLE_HOME/lib -locci –lclntsh -o occidml.exe

 

第一个参数是原文件, 第二参数是头文件所在地 第三个参数是库文件所在地  第四个和第五个参数是要连接的库名,第六个参数是 输出的可执行文件的名称

 

2 第二个平台

安装了客户端 SDK

 

下载地址:http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

注意数据库版本号和SDK的包

 

把*.so 移动到OCCI_LIB目录中

把 instantclient/sdk/include 里的*.h 复制到 OCCI_H目录中

 

编辑  ~/.bash_profile

OCCI_H=$OCCI_H:/home/es348/include/occi/sdk/include
OCCI_LIB=$OCCI_LIB:/home/es348/include/occi/lib
export OCCI_H
export OCCI_LIB

 

编译

g++ occidml.cpp -I$OCCI_H -L/home/es348/include/occi/lib -locci -lclntsh -o occidml.exe

 

SDK包中带来关于G++ 343的库。另外还有说明

 

我的是:

g++ -v

使用内建 specs。
目标:i386-redhat-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
线程模型:posix
gcc 版本 4.1.2 20070626 (Red Hat 4.1.2-14)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn