views:

2801

answers:

4

Oracle's instructions specify setting LD_LIBRARY_PATH. This makes my application dependent on random users' configuration and is very troublesome to set up.

How can I avoid having to set any environment variables?

http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxx86_64soft.html

related note for OS/X: http://stackoverflow.com/questions/684352

+4  A: 

Oracle's instantclient installation instructions specify that the user set LD_LIBRARY_PATH. This is very troublesome to manage for multiple users.

To use the instantclient without setting any environment variables:

Download the instantclient distribution from oracle.com. For doing non-java software development, you will need (assuming Oracle 10.2):

instantclient-basic-linux-x86_64-10.2.0.4.0.zip
instantclient-sdk-linux-x86_64-10.2.0.4.0.zip
instantclient-sqlplus-linux-x86_64-10.2.0.4.0.zip

Unzip the three files. This will give you a directory

instantclient_10_2/

Copy the files to /usr, which is one of the default places the dynamic loader searches.

sudo cp instantclient_10_2/sdk/include/*.h /usr/include
sudo cp instantclient_10_2/sqlplus         /usr/bin
sudo cp instantclient_10_2/*.so*           /usr/lib

If you use tnsnames.ora, copy it to /etc, which is the default global place the oracle runtime searches.

sudo cp tnsnames.ora /etc

Test with

/usr/bin/sqlplus scott/tiger@myoracle
Mark Harrison
I don't know that this is a great practice, but it does work!
pfctdayelise
+1  A: 

You could of course rename sqlplus to sqlplus.real and make a wrapper script:

#!/bin/sh

if [ "$LD_LIBRARY_PATH" = "" ]
then
        LD_LIBRARY_PATH=/what/ever
else
        LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/what/ever
fi

export LD_LIBRARY_PATH

exec sqlplus.real ${1+"$@"}
hlovdal
+2  A: 

Add the library path to /etc/ld.so.conf, then run /sbin/ldconfig. You don't need to set LD_LIBRARY_PATH for libraries installed in standard locations like /usr/lib because these locations are already configured in /etc/ld.so.conf.

David Phillips
A: 

For anyone playing with Solaris (like me!) coming from a Linux background, I found that @David Phillips solution worked well using the Solaris command crle -u -l /opt/instantclient

Thanks to post http://chrismiles.info/systemsadmin/solaris/articles/ld-path-customisation-on-solaris/

Aaron X