oracle 加载共享库时出错 libclntsh.so.11.1 无法打开

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26863989/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:37:03  来源:igfitidea点击:

Error loading shared libraries libclntsh.so.11.1 cannot open

c++linuxoraclecrontab

提问by Kumar Htabmas

Error while loading shared libraries: libclntsh.so.11.1 : cannot open shared obj file no such file. When running from crontab.

加载共享库时出错:libclntsh.so.11.1:无法打开共享 obj 文件,没有此类文件。从 crontab 运行时。

I complied my c++ program, its a proc program after compiling proc I will run the below command.

我编译了我的 c++ 程序,它是一个 proc 程序,在编译 proc 之后我将运行以下命令。

g++ filename.CPP -I $ORACLE_HOME/precomp/public -L $ORACLE_HOME/lib -lclntsh -o test 

I created a crontab to run it every min

我创建了一个 crontab 每分钟运行一次

$ crontab -l
* * * * * /home/test > /home/te.txt 2>&1 

I made a symbolic link of that library. But I'm getting above error inside te.txt

我做了那个库的符号链接。但我在 te.txt 中遇到了上述错误

Im searching this for past 2 days and also went through the similar question, but still I not able to clear the error.

我在过去 2 天里搜索了这个,也经历了类似的问题,但我仍然无法清除错误。

I'm not sure with LD_Library_pathor .bash_profile. how to include that library.

我不确定LD_Library_path.bash_profile。如何包含该库。

回答by Rahul R Dhobi

Your can export library path in your .bash_profile like

您可以在 .bash_profile 中导出库路径,例如

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

or you can copy your libclntsh.so in /usr/lib/ or /lib

或者您可以将 libclntsh.so 复制到 /usr/lib/ 或 /lib

回答by ibre5041

If you are on Linux (using GNU Binutils) you can also compile-in the library path directly into the binary. See -Wl,-rpath=...

如果您使用的是 Linux(使用 GNU Binutils),您还可以将库路径直接编译到二进制文件中。见 -Wl,-rpath=...

But anyway (unless you use Oracle instant client lib) you should also export ORACLE_HOME env. var in crontab. Otherwise your application will not by able to localize .nls nor .ora (tnsnames.ora) files.

但无论如何(除非您使用 Oracle 即时客户端库),您还应该导出 ORACLE_HOME 环境。crontab 中的 var。否则,您的应用程序将无法本地化 .nls 或 .ora (tnsnames.ora) 文件。