Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't load oracle.so

I am getting this exception:

Can't load '/usr/perl/lib/site_perl/5.8/x86_64-linux/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libclntsh.so.8.0: cannot open shared object file: 
No such file or directory at
/.../perl/lib/5.8/x86_64-linux/DynaLoader.pm line 169

If I do ls -ltr /.../perl/lib/site_perl/5.8/x86_64-linux/auto/DBD/Oracle/Oracle.so I see that the file is there. The process I am running also sets LD_LIBRARY_PATH before attempting to connect. A build and deploy on another machine doesn't produce the same error and runs fine. Running uname -sm gives Linux x86_64 on both machines. Is there something else that could cause this error?

like image 749
Niru Avatar asked Oct 11 '25 10:10

Niru


2 Answers

Another solution:
Just pass your Oracle path variables before you run any scripts: Like for perl you can do add below in beginning of your script:

BEGIN {
   my $ORACLE_HOME     = "/usr/lib/oracle/11.2/client64";
   my $LD_LIBRARY_PATH = "$ORACLE_HOME/lib";
   if ($ENV{ORACLE_HOME} ne $ORACLE_HOME
   || $ENV{LD_LIBRARY_PATH} ne $LD_LIBRARY_PATH
   ) {
      $ENV{ORACLE_HOME}     = "/usr/lib/oracle/11.2/client64";
      $ENV{LD_LIBRARY_PATH} = "$ORACLE_HOME/lib";
      exec { $^X } $^X, $0, @ARGV;
   }
}
like image 88
Ujjawal Khare Avatar answered Oct 14 '25 10:10

Ujjawal Khare


It looks like DBD::Oracle's Oracle.so is trying to open libclntsh.so.8.0 and can't find it. So you need to find out if that version of the shared library is installed.

Perform the following command:

$ locate libclntsh.so

You should get a list of files beginning with libclntsh.so. If you are lucky , libclntsh.so.8.0 will be among the results, and then you'll need to make sure that the directory that it lives in is on you load path. For instance my server has:

 $ locate libclntsh.so
 /home/oracle/11.2/lib/libclntsh.so
 /home/oracle/11.2/lib/libclntsh.so.10.1
 /home/oracle/11.2/lib/libclntsh.so.11.1

If locate fails completely, you can build the database using updatedb or you can try using find:

 find / -name 'libclntsh.so*' -print 

Use a pager or redirect stderr to a file because you might end up dealing with a lot of error messages from find, which is okay, but using less will allow you to just refresh the screen to see find's output.

like image 21
Len Jaffe Avatar answered Oct 14 '25 11:10

Len Jaffe