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: Sybase lib file not found
Date: Jan 13 1998 4:25PM

sandesh tattitali wrote:
> 
> Hi all,
>   I have this totally wierd problem that totally beats me.
> I have 2 machines , both running Solaris 2.5.1.
> Perl and Sybperl were compiled on a third m/c that also runs 2.5.1.
> The Perl installation on the 2 m/c is the same.
> However on removing the LD_LIBRARY_PATH variable from the user
> a/c on one machine, I get the following error
> ___________________________________________________________
> Can't load
> '/usr/local/lib/perl5/site_perl/sun4-solaris/auto/Sybase/CTlib/CTlib.
> so' for module Sybase::CTlib: ld.so.1: /usr/local/bin/perl: fatal:
> libct.so:
> can't open file: errno=2 at

errno 2 is "File not found".

You have to understand how ld.so (the dynamic loader) looks for
shared libraries when trying to resolve library references.

First, the name of the libraries that a perl .so module needs is
encoded in the file itself (for example in DBlib.so it needs access
to libsybdb.so, among others).

When perl builds the modules, it encodes the path to the libraries into
the file (at least it does so on Solaris 2.x). This is the path
where the library is found when the module is built.

When you say

use Sybase::DBlib;

in a perl script the dynamic loader (ld.so) will first look in
the directory that is hardcoded in the DBlib.so file. Then it
will look in any directory mentioned in LD_LIBRARY_PATH. Then in
the system library directories (/usr/lib and maybe /usr/local/lib).

As the Sybase libraries are usually found in a special directory 
(say /opt/sybase/lib, f.ex.) this means that if you move the 
DBlib.so file to a new machine where the libraries are located in
a different directory you will *HAVE* to set LD_LIBRARY_PATH
*before* running the script, or copy the libraries to /usr/lib.



> Another wierd thing is that even though I set LD_LIBRARY_PATH in the
> BEGIN clause, I still get this error on the problematic machine.

It is not possible to set LD_LIBRARY_PATH in a running script/program
and affect how ld.so is going to look for things.

You can only affect how ld.so will look for libraries in child
processes.

> sense that the errant machine is an Ultra whereas the 'good' machine
> is a Sparc 20.

There is nothing errant about this. It is perfectly logical behaviour
once you understand how ld.so works.

You can use the ldd(1) command to check library dependancies and 
locations on a binary.

For example, cd to $PERLLIB/site_perl/sun4-solaris/auto/Sybase/CTlib
and run ldd CTlib.so to see what I mean.

Michael
--
Michael Peppler       -||-  Data Migrations Inc.
mpeppler@datamig.com  -||-  http://www.mbay.net/~mpeppler