Hello,

I would like to provide some feedback which may be useful for build of 
DBD-Oracle.


I basically wanted to avoid using DYLD_LIBRARY_PATH  because the OS complains 
whenever an suid command is executed, such as ps(1).

So I did a bit of RTFM and googling   that I would like to share, as it maye be 
useful for others too :-)



1. I patched the shared libs and the executables using a small variation of the 
script found at this location
     
http://blog.caseylucas.com/2013/03/03/oracle-sqlplus-and-instant-client-on-mac-osx-without-dyld_library_path/
     My change is basically using @loader_path for the dylibs and 
@executable_path for the actual executables.


2.  Added the 2 symlinks as usual:

 ./libclntsh.dylib -> libclntsh.dylib.11.1
 ./libocci.dylib -> libocci.dylib.11.1


3.  Make sure that instantclient_11_2 is in my PATH  (basically I should be 
able to launch sqlplus ) and build as usual:
        perl Makefile.PL   && make

4. I noticed that the produced bundle fails to load the libclnt.dylib  and 
checking with otool -L revealed that the LD_RUN_PATH and -R options are not 
honored on OS/X 10.8

$ perl -w -Mblib -MDBD::Oracle -le 1
Can't load 
'/Users/phil/X1/DBD-Oracle-1.58/blib/arch/auto/DBD/Oracle/Oracle.bundle' for 
module DBD::Oracle: 
dlopen(/Users/phil/X1/DBD-Oracle-1.58/blib/arch/auto/DBD/Oracle/Oracle.bundle, 
1): Library not loaded: libclntsh.dylib.11.1
  Referenced from: 
/Users/phil/X1/DBD-Oracle-1.58/blib/arch/auto/DBD/Oracle/Oracle.bundle
  Reason: image not found at /usr/local/ActivePerl-5.16/lib/DynaLoader.pm line 
195.
 at -e line 0.
Compilation failed in require.
BEGIN failed--compilation aborted.


So, I used otool and checked the bundle:

$ otool -L 
/Users/phil/X1/DBD-Oracle-1.58/blib/arch/auto/DBD/Oracle/Oracle.bundle
/Users/phil/X1/DBD-Oracle-1.58/blib/arch/auto/DBD/Oracle/Oracle.bundle:
        libclntsh.dylib.11.1 (compatibility version 0.0.0, current version 
0.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 169.3.0)

Modifying the bundle before installation :

install_name_tool \
        -change libclntsh.dylib.11.1 @rpath/libclntsh.dylib.11.1 \
        -add_rpath /usr/local/instantclient_11_2 \
        blib/arch/auto/DBD/Oracle/Oracle.bundle

And now it works :-)

$ env PERL_DL_NON_LAZY=1 perl -w -M5.016  -MDBI -Mblib -MDBD::Oracle -le 
"DBI->connect('dbi:Oracle:host=localhost;port=1521;sid=orcl;', 'system', 
'oracle') && say 'it works'";
it works

This leaves me under the (bad) impression that LD_RUN_PATH is ignored on 
Mountain Lion (10.8.3) ?
If this is the case, maybe some changes required in MakeMaker...

But anyway, thanks to install_name_tool  I have a working DBD::Oracle that 
doesn't require DYLD_LIBRARY_PATH  !


I hope this information may be useful -- eventually as an addition to this 
document 
http://search.cpan.org/dist/DBD-Oracle/lib/DBD/Oracle/Troubleshooting/Macos.pod

Best regards,
/Philippe.


#======== Patch script looks like this now: =============

#!/bin/sh
# script to change the dynamic lib paths and ids for oracle instant client
# exes and libs

# proces all the executable files in this directory
for exe in sqlplus adrci genezi uidrvci
do
    echo adjusting executable $exe
    baseexe=`basename $exe`
    otool -L $exe | awk '/oracle/ {print $1}' | while read lib
    do
        echo adjusting lib $lib
        baselib=`basename $lib`
        if [ "$baseexe" = "$baselib" ]
        then
            echo changing id to $baselib for $exe
            install_name_tool -id $baselib $exe
        else
            echo changing path id for $lib in $exe
            install_name_tool -change $lib @executable_path/$baselib $exe
        fi
    done
done

for exe in *dylib* 
do
    echo adjusting executable $exe
    baseexe=`basename $exe`
    otool -L $exe | awk '/oracle/ {print $1}' | while read lib
    do
        echo adjusting lib $lib
        baselib=`basename $lib`
        if [ "$baseexe" = "$baselib" ]
        then
            echo changing id to $baselib for $exe
            install_name_tool -id $baselib $exe
        else
            echo changing path id for $lib in $exe
            install_name_tool -change $lib @loader_path/$baselib $exe
        fi
    done
done

#----------------------------------------------------------


Reply via email to