views:

454

answers:

3

A compulsion of LD_PRELOAD on HP platform only and not on other unix flavors (AIX,Linux, and Solaris).

I built Perl Module XML::LibXML::Common on all of Unix flavors.I had to specifically do LD_PRELOAD for libcl.2 library on HP Platform only. While on other unix platforms nothing as such was required.

Is this an OS behaviour or something really missing in HP loader/compiler?

I was running a perl script which simply creates a new object of "XML::LibXML::SAX"

use XML::LibXML::SAX;
$x = XML::LibXML::SAX->new();

and it complained for

Can't load 'site_perl/5.8.8/PA-RISC2.0-thread-multi/auto/XML/LibXML/Common/Common.sl' for module XML::LibXML::Common: Exec format error

and when i do the LD_PRELOAD for libcl.2 the error goes away and the Perl is built for a multi threaded support.

+1  A: 

Your question isn't clear...why did you have to use LD_PRELOAD?

Is it because HP-UX uses SHLIB_PATH instead of LD_LIBRARY_PATH, so you were setting the wrong environment variable?

It has other spellings on other platforms, too - Solaris and Linux happen to share much the same set of env. vars. MacOS X uses DYLIB_LIBRARY_PATH; AIX uses use LIBPATH, I believe.

Jonathan Leffler
Yes I had to do LD_PRELOAD on HP.I am not talking about environment for where to find the library with LIBPATHS (guess the synonyms vary as per OS).What I meant is, I had to specifically load a library and this is nothing to do with finding a library specifying in env variables.hope i make sense.
kadeshpa
Why did you have to load the library? Was it to override symbols from another library? Is there a libcl.sl that you needed to replace? At the moment, you have not explained what went wrong before you did the LD_PRELOAD. So, I'm confused; the lack of other answers suggests others are too.
Jonathan Leffler
+1  A: 

I think you are asking why you have to use it. If you are running Perl multi-threaded one of the libraries you are calling is getting loaded before libc and it is likely single threaded. As part of its dependency processing, it is attempting to load a multi-threaded library in your environment. By using LD_PRELOAD I think you are using the principle of library interposition to force that library to load prior to loading the unsafe library. The notion of interposition is a complex one and you might gain some benefit from the following link:

Excerpt:

To use library interposition, you need to create a special shared library and set the LD_PRELOAD environment variable. When LD_PRELOAD is set, the dynamic linker will use the specified library before any other when it searches for shared libraries.

ojblass
A: 

I'm not sure if this is relevant, but it probably is. THe Perl included with HP-UX is not the standard Perl but is a copy of ActiveState Perl - along with whatever strangeness that might include. If you find Perl acting strangely on HP-UX in contrast to every other environment - check whether ActiveState Perl is at fault.

David