ocilib linux编译安装
1.首先下载ocilib到自己目录
github:https://github.com/vrogier/ocilib
2.在下载instantclient 11.2.2的文件:
instantclient-basic-linux-11.2.0.3.0.zip
instantclient-sdk-linux-11.2.0.3.0.zip
都解压生成在
/usr/local/instantclient_12_2
3.配置环境变量
export ORACLE_HOME=/usr/local/instantclient_12_2 export PATH=$ORACLE_HOME:$PATH export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME #export TNS_ADMIN=$ORACLE_HOME/network/admin #export NLS_LANG="Simplified Chinese_china".ZHS16GBK
4.
./configure
a.出错找不到include,修改configure
大约在line
12113 # find out the Oracle public OCI headers path
12114 ac_headers_path=$ac_oracle_home/sdk/include
12115 if test "$ac_headers_path" = NO; then
12116 if test "$ac_oracle_home" != NO; then
12117 test_include_path=$ac_oracle_home/rdbms/public
12118 if test -d "$test_include_path"; then
12119 ac_headers_path=$test_include_path
12120 else
12121 test_include_path=$ac_oracle_home/rdbms/demo
12122 if test -d "$test_include_path"; then
12123 ac_headers_path=$test_include_path
12125 fi
12126 fi
12127 fi
12128 fi
b.“aclocal-1.15”在你的系统上缺少“编译时的警告
运行前./configure
尝试运行autoreconf -f -i
。autoreconf程序根据需要自动运行autoheader,aclocal,automake,autopoint和libtoolize。
具体见:http://stackoverflow.com/questions/33278928/how-to-overcome-aclocal-1-15-is-missing-on-your-system-warning-when-compilin
make
需要root
make install
测试实例:
#include <stdio.h>
#include <iostream>
#include <list>
#include <memory>
#include "ocilib.h"
using namespace std; int main(int argc, char *argv[])
{
OCI_Connection* cn;
OCI_Statement* st;
OCI_Resultset* rs; OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT); cn = OCI_ConnectionCreate("//192.168.52.129/ORCL", "system", "oracle", OCI_SESSION_DEFAULT);
st = OCI_StatementCreate(cn); OCI_ExecuteStmt(st, "SELECT * from \"t_stu\""); rs = OCI_GetResultset(st); while (OCI_FetchNext(rs))
{
printf("%i - %s\n", OCI_GetInt(rs, ), OCI_GetString(rs,));
} OCI_Cleanup(); return EXIT_SUCCESS;
}
export ORACLE_HOME=/usr/local/instantclient_12_2
export PATH=$ORACLE_HOME:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
g++ main.cpp -I/usr/local/ocilib/include -L/usr/local/ocilib -locilib
提示:
这里使用静态库
g++ -g -std=c++11 test_oracle.cpp file.cpp -o process -I/usr/local/ocilib/include -L/usr/local/ocilib -L/usr/local/instantclient_12_2 -lclntsh -locilib -lrt -lpthread
最新文章
- 初始通过 FastClick.notNeeded 方法判断是否需要做后续相关处理
- Verify Preorder/Inorder/Postorder Sequence in Binary Search Tree
- PHP Header下载文件在IE文件名中文乱码问题
- RESTful Webservice (一) 概念
- web.xml文件中配置ShallowEtagHeaderFilter需注意的问题
- Scut 上线后遇到的问题
- 从c#基础到java基础的学习的感悟
- 修改MyEclipse字体大小及颜色
- tensorflow中tf.ConfigProto()用法解释
- StringUtils方法介绍
- Structs复习 Structs标签
- 对va_list; va_start ; va_end ;vsprintf理解(转)
- 【HAOI2014】贴海报
- 【WPF】当 ItemsSource 正在使用时操作无效。改用 ItemsControl.ItemsSource 访问和修改元素
- 【go】用Golang的 http 包建立 Web 服务器
- Qt使用QNetworkAccessManager实现Http操作
- 使用Navicat for MySQL
- mysql数据库将表移动到新数据库,或者说更改数据库名字
- python+appuim 处理系统权限弹窗
- 团队项目-第十次scrum 会议