luxAeterna has asked for the wisdom of the Perl Monks concerning the following question:

Oh Wisest among the Wise,

I humbly apologize for my ignorance, as I am trying to reproduce a connection to an Oracle Data Base from a working one in another machine and I am getting the next compilation error:

Can't load '/soft/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libclntsh.so.11.1: cannot open shared object file: No such file or directory at /soft/perl-5.10.1/lib/5.10.1/x86_64-linux-thread-multi/DynaLoader.pm line 200. at /users/rum00/exploit/script/rum_verify_database_connection.pl line 19

I have added a debug line before the line 200 in DynaLoader.pm line 200.

print "========> $file\n"; my $libref = dl_load_file($file, $module->dl_load_flags) or croak("Can't load '$file' for module $module: ".dl_error());

Obtained:

========> /soft/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux-thread-multi/auto/DBI/DBI.so

========> /soft/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so

Then I checked these files and their permissions, Obtaining:

____________________________

$ ls -ltr /soft/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux-thread-multi/auto/DBI | grep DBI.so

> -r-xr-xr-x 1 root sys 150632 Jan 24 2013 DBI.so

$ ls -ltr /soft/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux-thread-multi/auto/DBD/Oracle | grep Oracle.so

> -r-xr-xr-x 1 root sys 296365 Apr 30 2013 Oracle.so

____________________________

So the modules do exist, in the expected place, they do have the right permissions... what could be happening that they can't be loaded?

Thank you in advance, Ramen

  • Comment on Can't load '/soft/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so'
  • Download Code

Replies are listed 'Best First'.
Re: Can't load '/soft/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so'
by Corion (Patriarch) on Feb 06, 2015 at 11:52 UTC

    I think the problem is not with Oracle.so but that Oracle.so loads other .so files, which might load more .so files, and one of them is libclntsh.so.11.1, and that file is not found (or not in $ENV{LD_LIBRARY_PATH}).

    You could try looking at the output of ld Oracle.so and maybe that lists which files need to be present/readable for it to load.

      Not ld Oracle.so but ldd Oracle.so, otherwise you're right.

      Much to my dismay, you are completely right

      The problem is, I don't have an Oracle client installed in the machine. It is a server that has to communicate with a Data Base in a remote machine

      The script was supposed to be ran in the server precisely to perform a simple query to a remote database and check that the connectivity is OK

      I ran a:

      $ ldd /soft/perl-5.10.1/bin/perl verify_database_connection.pl

      To check which libraries and modules the script needs to load and where it is trying to look for them, and got:

      open("/soft/ora1120/db/lib/tls/x86_64/libclntsh.so.11.1", O_RDONLY) = +-1 ENOENT (No such file or directory) stat("/soft/ora1120/db/lib/tls/x86_64", 0x7fff4406c740) = -1 ENOENT (N +o such file or directory) open("/soft/ora1120/db/lib/tls/libclntsh.so.11.1", O_RDONLY) = -1 ENOE +NT (No such file or directory) stat("/soft/ora1120/db/lib/tls", 0x7fff4406c740) = -1 ENOENT (No such +file or directory) open("/soft/ora1120/db/lib/x86_64/libclntsh.so.11.1", O_RDONLY) = -1 E +NOENT (No such file or directory) stat("/soft/ora1120/db/lib/x86_64", 0x7fff4406c740) = -1 ENOENT (No su +ch file or directory) open("/soft/ora1120/db/lib/libclntsh.so.11.1", O_RDONLY) = -1 ENOENT ( +No such file or directory) stat("/soft/ora1120/db/lib", 0x7fff4406c740) = -1 ENOENT (No such file + or directory) open("/etc/ld.so.cache", O_RDONLY) = 5 fstat(5, {st_mode=S_IFREG|0644, st_size=53762, ...}) = 0 mmap(NULL, 53762, PROT_READ, MAP_PRIVATE, 5, 0) = 0x7f012034a000 close(5) = 0 open("/lib64/tls/x86_64/libclntsh.so.11.1", O_RDONLY) = -1 ENOENT (No +such file or directory) stat("/lib64/tls/x86_64", 0x7fff4406c740) = -1 ENOENT (No such file or + directory) open("/lib64/tls/libclntsh.so.11.1", O_RDONLY) = -1 ENOENT (No such fi +le or directory) stat("/lib64/tls", 0x7fff4406c740) = -1 ENOENT (No such file or d +irectory) open("/lib64/x86_64/libclntsh.so.11.1", O_RDONLY) = -1 ENOENT (No such + file or directory) stat("/lib64/x86_64", 0x7fff4406c740) = -1 ENOENT (No such file or d +irectory) open("/lib64/libclntsh.so.11.1", O_RDONLY) = -1 ENOENT (No such file o +r directory) stat("/lib64", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0 open("/usr/lib64/tls/x86_64/libclntsh.so.11.1", O_RDONLY) = -1 ENOENT +(No such file or directory) stat("/usr/lib64/tls/x86_64", 0x7fff4406c740) = -1 ENOENT (No such fil +e or directory) open("/usr/lib64/tls/libclntsh.so.11.1", O_RDONLY) = -1 ENOENT (No suc +h file or directory) stat("/usr/lib64/tls", 0x7fff4406c740) = -1 ENOENT (No such file or d +irectory) open("/usr/lib64/x86_64/libclntsh.so.11.1", O_RDONLY) = -1 ENOENT (No +such file or directory) stat("/usr/lib64/x86_64", 0x7fff4406c740) = -1 ENOENT (No such file or + directory) open("/usr/lib64/libclntsh.so.11.1", O_RDONLY) = -1 ENOENT (No such fi +le or directory)

      The machine where the connection to the Oracle database works does have the libclntsh.so.11.1 module in

      $ ls -ltr /soft/ora1020/lib | grep libclntsh.so.11.1

      lrwxrwxrwx 1 root sys 17 Aug 20 2012 libclntsh.so.11.1 -> libclntsh.so.10.1

      Then I copied the module from the remote machine to a local folder in my machine and edited the start as:

      MYORACLELIBS=/pathtothefolder ; export MYORACLELIBS LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${MYORACLELIBS} ; export LD_LIBRARY_P +ATH

      I still located one more Oracle module it needed to compile

      Unluckily, once it compiled, it failed, because it needs an Oracle client installed. My code:

      use strict; use warnings; use DBD::Oracle; use DBI; my $dbh = DBI->connect("dbi:Oracle://$host:1522:$db",$dbUser, $dbPass) + or die;

      It died with the error

      DBI connect('//yval1bk0:1522:RUM','DYNATRACE',...) failed: ERROR OCIEnvNlsCreate. Check ORACLE_HOME (Linux) env var  or PATH (Windows) and or NLS settings, permissions, etc. at /users/rum00/exploit/script/rum_verify_database_connection.pl line 44

      I am not going to request the extra installation of an oracle client in a server that does not host any database

      So I'll continue with my research but I'm afraid I will have to use the existing .jar to do this verification, instead of my adored Perl :)

        I am not going to request the extra installation of an oracle client in a server that does not host any database

        That is exactly the kind of machine that needs a client ... and its exactly what DBD::Oracle needs ... how did you install DBD::Oracle without having a client installed? Thats impossible you know :) Maybe you should just find the already installed client and adjust your LD_LIBRARY_PATH or ... so that DBD/Oracle.so can find it

        You likely don't need a full fledged client install, but can get away with an instant client instead