PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at mbay dot net>
Subject: Re: LD_LIBRARY_PATH on Solaris
Date: Aug 28 1998 3:56PM

Thomas Klein writes:
 > > Why do you need LD_LIBRARY_PATH in the first place?
 > 
 > I do not need LD_LIBRARY_PATH, but i do have some users which will have it.
 > 

Again - my advice is to get these users to change their
LD_LIBRRAY_PATH settings.

 > > My advice is to remove /usr/lib from LD_LIBRARY_PATH.
 > 
 > That's only possible if i write a shell-wrapper for every sybperl
 > script which strips the path out.

Sorry - but unless you agree to the extra startup time it will take to 
do two forks if LD_LIBRARY_PATH includes /usr/lib then the only other
choice is to get your users to remove it from their setup (yes I know
I am repeating myself).

 > 
 > My intention is to write robust scripts which will work with or without
 > the LD_LIBRARY_PATH set.
 > 
 > Can somebody tell me why this BEGIN doesn't work?
 > 
 > >  > BEGIN {
 > >  >     # Mandatory settings for the Sybase CTLib package
 > >  >     # This instructions have to be executed before the
 > >  >     # package CTLib is loaded!
 > >  >         $ENV{'LD_LIBRARY_PATH'}="/opt/local/sybase/lib:".$ENV{LD_LIBRARY_PATH};
 > >  >         $ENV{'SYBASE'}="/opt/local/sybase";
 > >  > }

You can't set LD_LIBRARY_PATH and expect it to be active for the
currently running executable. That's just a fact of life, and the way
that ld.so works.

You could do something like this (untested):

#!/usr/local/bin/perl

BEGIN {
   if($ENV{LD_LIBRARY_PATH} =~ m|/usr/lib:?|) {
	$ENV{LD_LIBRARY_PATH = "/opt/local/sybase/lib:$ENV{LD_LIBRARY_PATH}";
	exec $0;     # re-exec myself
}

use Sybase::CTlib;

etc...

This *might* work, but again it requires perl to be re-exec'ed.

Michael
-- 
Michael Peppler         -||-  Data Migrations Inc.
mpeppler@mbay.net       -||-  http://www.mbay.net/~mpeppler
Int. Sybase User Group  -||-  http://www.isug.com