美文网首页
linux下使用C语言连接oracle数据库

linux下使用C语言连接oracle数据库

作者: 明明就_c565 | 来源:发表于2018-10-24 18:23 被阅读0次

    下载地址

    https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

    需要注册oracle账户

    下载三个rpm包(对应oracle数据库的版本)

    [root@localhost oracle]# ls

    oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm  oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm

    oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm

    [root@localhost oracle]#

    安装

    [root@localhost oracle]#

    [root@localhost oracle]# rpm -ivh oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm

    Preparing...                ########################################### [100%]

      1:oracle-instantclient12.########################################### [100%]

    [root@localhost oracle]# rpm -ivh oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm

    Preparing...                ########################################### [100%]

      1:oracle-instantclient12.########################################### [100%]

    [root@localhost oracle]# rpm -ivh oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm

    Preparing...                ########################################### [100%]

      1:oracle-instantclient12.########################################### [100%]

    设置环境变量

    [root@localhost oracle]# export ORACLE_HOME=/usr/lib/oracle/12.1/client64

    [root@localhost oracle]# export TNS_ADMIN=$ORACLE_HOME/network/admin

    [root@localhost oracle]# export NLS_LANG='simplifiedchinese_china.UTF8'

    [root@localhost oracle]# export LD_LIBRARY_PATH=$ORACLE_HOME/lib

    [root@localhost oracle]# export PATH=$ORACLE_HOME/bin:$PATH

    编译

    [root@localhost oracle]# g++ -o test -I /usr/include/oracle/12.1/client64/ -L/usr/lib/oracle/12.1/client64/lib/ oracle_test.cpp -lclntsh -locci -lmql1 -lipc1 -lnnz12 -lons -lclntshcore -Wall -O -g

    [root@localhost oracle]# ls

    oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm  oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm  test

    oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm  oracle_test.cpp

    相关文章

      网友评论

          本文标题:linux下使用C语言连接oracle数据库

          本文链接:https://www.haomeiwen.com/subject/fnbxtqtx.html