0

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

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

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 -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

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

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

fedorqui
  • 275,237
  • 103
  • 548
  • 598
Kumar Htabmas
  • 45
  • 1
  • 2
  • 11
  • The command `/home/test > /home/te.txt 2>&1` does not make sense. You should instead have something like `/bin/sh /path/to/script` and so on. – fedorqui Nov 12 '14 at 12:57

2 Answers2

4

Your can export library path in your .bash_profile like

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

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

Rahul R Dhobi
  • 5,668
  • 1
  • 29
  • 38
  • I will try this . Could I able to do this without root user privilege. – Kumar Htabmas Nov 11 '14 at 13:52
  • 1
    exporting path doesn't require root user privilege but if you need to copy lib to /usr/lib/ or /lib then root user privilege required – Rahul R Dhobi Nov 12 '14 at 04:17
  • My .bash_profile contains export LD_LIBRARY_PATH, poiting correctly to $oracle_home/lib. Even now I'm getting the same error.. – Kumar Htabmas Nov 12 '14 at 09:33
  • I think crontab executing your binary using root so you need to add this to root user's .bash_profile or you need to run cron using other user which .bash_profile have exported path – Rahul R Dhobi Nov 12 '14 at 11:07
0

If you are on Linux (using GNU Binutils) you can also compile-in the library path directly into the binary. See -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.

Community
  • 1
  • 1
ibre5041
  • 4,903
  • 1
  • 20
  • 35