[Phoenix-pm] DBD/DynaLoader question

Scott Walters scott at illogics.org
Wed Jul 27 01:20:45 PDT 2005


Hi Michael,

I'm guessing LD_LIBRARY_PATH needs to be set before the Perl process
is created.  The behavior you're seeing is that of the dlopen() Unix
system call itself.  But I've never tried munging anything that ELF
uses -- I've only banged maybe PATH and one or two other things.  I
guess I kind of exected LD_LIBRARY_PATH would be copied and cached
at process start-up.

I'm confused -- you say this works fine, but then you say no matter 
where you put it, it acts as if LD_LIBRARY_PATH wasn't set 
property.  You mean it works fine if you do this from the shell
but not fine if you do it from within the program?

  #!/bin/sh
  export LD_LIBRARY_PATH="/opt/sybase/lib:$LD_LIBRARY_PATH"
  exec /usr/bin/perl
  print qq{Hi! $ENV{LD_LIBRARY_PATH}\n};

But that's fugly ;)

It might be easier to just insert /opt/sybase/lib into the top of
/etc/ld.so.conf and run ldconfig.  

You can build the module list into Perl, in which case modules
configure themselves with the same information.  I think that's
the prompt that looks like:

  Directories to use for library searches? [/usr/local/lib /lib /usr/lib]

But you can also plug libraries into ExtUtils::MakeMaker based 
Makefile.PL's.  From the ExtUtils::MakeMaker man page:

       LIBS
         An anonymous array of alternative library specifications to be searched for (in order) until at least one library
         is found. E.g.

           'LIBS' => ["-lgdbm", "-ldbm -lfoo", "-L/path -ldbm.nfs"]

         Mind, that any element of the array contains a complete set of arguments for the ld command. So do not specify

           'LIBS' => ["-ltcl", "-ltk", "-lX11"]

         See ODBM_File/Makefile.PL for an example, where an array is needed. If you specify a scalar as in

           'LIBS' => "-ltcl -ltk -lX11"

You'd need to edit the Makefile.PL and cram something of this format into there,
such as LIBS => '-L/opt/sybase/lib'.  That might not make it the first library
searched, though.

A lot of this is guess work taken from vague memories.  I hope it doesn't
induce more confusion than it clears up. 

Good luck!
-scott 


On  0, Michael Friedman <friedman at highwire.stanford.edu> wrote:
> Help?
> 
> I've installed DBI and DBD::Sybase, made sure everything can compile, 
> and even tested it. So I know the modules are working. The only problem 
> is that the module requires a certain order of directories in the 
> LD_LIBRARY_PATH and I can't seem to set that automatically. (This is on 
> Solaris.)
> 
> I have the ENV setting code as follows. It works fine and sets the 
> environment for the script properly.
> BEGIN
> {
> 	if ($ENV{LD_LIBRARY_PATH})
> 	{
> 			$ENV{LD_LIBRARY_PATH} = '/opt/sybase/lib:' . $ENV{LD_LIBRARY_PATH};
> 	}
> 	else
> 	{
> 		$ENV{LD_LIBRARY_PATH} = '/opt/sybase/lib';
> 	}
> 	$ENV{SYBASE} = '/opt/sybase';	
> }
> 
> What I don't have is the place to put it. I've put it in my script, in 
> my shared module, even in DBD::Sybase.pm itself! When I try to even 
> load DBD::Sybase, it always acts as if the LD_LIBRARY_PATH was not set 
> properly. It seems to be loading in the Sybase.so file before it runs 
> the BEGIN block in DBD::Sybase itself. I don't know anything about the 
> DynaLoader, so I'm not sure if it's safe to try inserting the code 
> there -- or even where "there" is.
> 
> Anyone have any experience with DynaLoader and any thoughts that might 
> help?
> 
> Thanks much!
> -- Mike
> ---------------------------------------------------------------------
> Michael Friedman                  HighWire Press, Stanford Southwest
> Phone: 480-456-0880                                   Tempe, Arizona
> FAX:   270-721-8034                  <friedman at highwire.stanford.edu>
> ---------------------------------------------------------------------
> 
> _______________________________________________
> Phoenix-pm mailing list
> Phoenix-pm at pm.org
> http://mail.pm.org/mailman/listinfo/phoenix-pm


More information about the Phoenix-pm mailing list