Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
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: /usr/local/bin/perl: fatal:
> can't open file: errno=2 at

errno 2 is "File not found".

You have to understand how (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 it needs access
to, 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 ( will first look in
the directory that is hardcoded in the 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 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 is going to look for things.

You can only affect how will look for libraries in child

> 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 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 to see what I mean.

Michael Peppler       -||-  Data Migrations Inc.  -||-