简体   繁体   English

如何将oracle oci库添加到C ++ Eclipse

[英]how to add oracle oci libraries to C++ eclipse

I'm writing a method for Oracle in C++. 我正在用C ++编写针对Oracle的方法。 I'm using the OCI library with Eclipse as my IDE. 我将OCI库与Eclipse一起用作我的IDE。 The code compiled completely but I'm getting this runtime error: 该代码已完全编译,但出现此运行时错误:

"error while loading shared libraries: libocci.so.11.1: cannot open shared object file: No such file or directory "

I included occi and clntsh and nnz11 through properties > c/c++ general /Path and symbols > libraries 我通过属性> c / c ++常规/路径和符号>库包括了occi和clntsh和nnz11

I don't know how to fix this error, please help thanks you 我不知道该如何解决此错误,请帮助谢谢

IDE wont take like libocci.so.11.1 you have to convert into like libocci.so IDE不会像libocci.so.11.1那样转换为libocci.so

ln -s libocci.so.11.1 ln -s libocci.so.11.1

then it will be renamed to libocci.so 然后将其重命名为libocci.so

then compile the code 然后编译代码

Your compiler finds the libraries because your project probably specifies where to look for libs (-L flag on the linker command line). 您的编译器会找到这些库,因为您的项目可能会指定在何处查找库(链接器命令行上的-L标志)。 But the runtime linker needs to find the libs as well. 但是运行时链接程序也需要找到这些库。

I assume you're running it on linux. 我假设您正在Linux上运行它。 You have 2 options: 您有2个选择:

  1. A temporary solution is to define in your environment LD_LIBRARY_PATH= full path to dir where libocci.so* is installed . 临时解决方案是在您的环境中定义LD_LIBRARY_PATH = full path to dir where libocci.so* is installed I'm not very familiar with eclipse, but there's likely a setting to change the runtime environment. 我对eclipse不太熟悉,但是可能有一个设置可以更改运行时环境。 You could also set LD_LIBRARY_PATH and then run ecplise in that env. 您还可以设置LD_LIBRARY_PATH,然后在该环境中运行ecplise。

    $ export LD_LIBRARY_PATH=... $ export LD_LIBRARY_PATH = ...

    $ command to run eclipse $命令运行eclipse

  2. A permanent solution is to add the full path to the dir. 永久解决方案是将完整路径添加到目录中。 where the libs are to the file /etc/ld.so.conf, or better: create a file /etc/ld.so.conf.d/oracle and put the path in that file, nothing else. 库位于文件/etc/ld.so.conf或更高级的位置:创建文件/etc/ld.so.conf.d/oracle,并将路径放在该文件中,仅此而已。 Then, as root, run ldconfig. 然后,以根用户身份运行ldconfig。

wow . 哇 。 finally i did it , by one variable and put it into .bashrc 最后我做了一个变量,将其放入.bashrc

1- export LD_LIBRARY_PATH=/opt/oracle/instantclient "The Path of libraries" and then 2- root@user:~# vi .bashrc "Make sure you are in root" 3- LD_LIBRARY_PATH=/opt/oracle/instantclient/ "Add this two lines into file" export LD_LIBRARY_PATH 1-导出LD_LIBRARY_PATH = / opt / oracle / instantclient“库的路径”,然后2- root @ user:〜#vi .bashrc“确保您在root中” 3- LD_LIBRARY_PATH = / opt / oracle / instantclient /将这两行添加到文件中” export LD_LIBRARY_PATH

:) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM