On Linux (currently testing RHEL6.5), it appears that LD_LIBRARY_PATH must be defined/exported *outside* my script in order to load DBD::Oracle successfully. This is not so on AIX (LIBPATH), and I wasn't expecting it on Linux either. Setting $ENV{LD_LIBRARY_PATH} in a BEGIN block at the top of my script gets the standard
install_driver(Oracle) failed: Can't load '/home/jrw/perl_dbi/linux/li +b/perl5/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so' for modu +le DBD::Oracle: libclntsh.so.18.1: cannot open shared object file: No + such file or directory at /usr/lib64/perl5/DynaLoader.pm line 200. at (eval 38) line 3
whereas exporting LD_LIBRARY_PATH *before* running perl -e allows the script to succeed. Does DynaLoader cache the initial LD_LIBRARY_PATH during script startup? Or is something else going on? Test script:
export DIR=/home/jrw/perl_dbi/linux unset LD_LIBRARY_PATH # export LD_LIBRARY_PATH=$DIR/oracle_instantclient perl -e ' use strict; use warnings; BEGIN { $ENV{LD_LIBRARY_PATH} = "$ENV{DIR}/oracle_instantclient" } use lib "$ENV{DIR}/lib/perl5"; use DBI; my @drivers = DBI->available_drivers; print "Drivers = @drivers\n"; foreach my $driver (@drivers) { my @databases = DBI->data_sources($driver); print " Driver: $driver, data sources = @databases\n"; } '

In reply to Why must LD_LIBRARY_PATH be defined outside script for DBD::Oracle? by jrw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.