MidLifeXis has asked for the wisdom of the Perl Monks concerning the following question:

Loading a 32-bit library via DynaLoader into 64-bit Perl 5.8.8 on HP-UX 11i appears to be difficult, at least with a library from one of my vendors. I am getting a generic DynaLoader message, that when running under the debugger turns out being a "Bad magic number" message, which I am assuming is indicative of trying to load a 32-bit library into a 64-bit perl.

The vendor does not have a 64-bit version of the library available (although they have "certified" the application to run under 64-bit HP-UX 11i). I have applied appropriate pressure, but, as is typical with this vendor, the solution will be a long time coming.

I guess I am looking for build flag advice or possible tips on getting the vendor's library to load. Perl is compiled with HP's hp-gcc64-3.4.5 distribution. If I do need to revert to a 32 bit version of gcc, then so be it, but I would rather not.

Any ideas?

--MidLifeXis

  • Comment on Loading a 32-bit library via DynaLoader into 64-bit Perl 5.8.8 on HP-UX 11i

Replies are listed 'Best First'.
Re: Loading a 32-bit library via DynaLoader into 64-bit Perl 5.8.8 on HP-UX 11i
by almut (Canon) on Jan 31, 2007 at 02:34 UTC

    Generally, you can't mix different binary formats in one program (i.e. executable + libs). If this is an Itanium based system (which I'm assuming), you typically have support for IA64 (native) and - for compatibility - IA32 (sometimes via emulation) and PA-RISC (the latter comes in several flavors, too). This doesn't always make things easy...

    I'm afraid the short answer is, you'll have to build a Perl that matches your library - unless you can get a library that matches your Perl (from your description I'm assuming you don't have the sources of the lib).

    BTW, what kind of library is this? Does your vendor actually ship a precompiled Perl extension without an appropriate Perl executable, or is this some more generic library for which you want to write the XS glue code yourself?

    In any case, you need to find out exactly what type of lib you have. Basic info can be obtained with "file yourlib.s[lo]" (unfortunately, some HP-UXs come with a slightly buggy "magic" file (upon which the file utility bases its decisions), so you might want to cross-check with "chatr yourlib.s[lo]" (though the latter will usually only work for either IA/ELF (new) or PA-RISC (old)) ...).   Things are somewhat complicated by the fact that it's recommended to also use the same compiler (system cc vs. gcc? / versions?) - ideally with the same options. So you'll probably want to ask your vendor for those details.

    I'm sorry, but it's hard to give precise instructions without knowing more details (and building software under HP-UX is generally not for the faint-of-heart), so all I can do at the moment is wish you good luck... :)

      Generally, you can't mix different binary formats in one program (i.e. executable + libs)

      Yeah, that is what I was figuring.

      A little more information. This is a PA-RISC 2.0 system, library from vendor is an interface library, precompiled, and we <paraphrase>should have a compatable version of PERL (sic) for, get the source from www.cpan.org</paraphrase> blah blah blah. Of course there are no instructions as to what flags it needs, the Makefile.PL is definitely not perlish (it is called only for the "make uninstall" and "make install" targets, rest of commands, all common make targets, are done with an install.sh script), etc. I cannot say that I have seen anyone who "speaks Perl" there.

      Vendors library is SOM, and my perl is ELF, so I was guessing that I would need to recompile in 32-bit SOM mode. Oh well.

      I have the SA searching out a 32-bit gcc, and will be re-running my system build script using that. I guess I wait for the next upgrade (12 months or so) to go to 64-bit. Maybe by then they will support Itanium.

      Oh well, this is starting to turn into a rant / gripe, so I should probably just leave it at that. Thanks for your feedback.

      --MidLifeXis

Re: Loading a 32-bit library via DynaLoader into 64-bit Perl 5.8.8 on HP-UX 11i
by Tux (Canon) on Jul 12, 2007 at 06:32 UTC

    Sorry to chime in late ...

    All comments already given so far are valid. (Shared) libraries and objects on HP-UX of different architecture do not mix. That is not only the case for 32bit vs 64bit, but also for PA-RISC on Itanium. IA64 has native support for PA-RISC objects, but they do not load in Itanium code.

    Maybe you can skip the build phase and fetch my prebuilt binary depots that include both a 32bit (/opt/perl) and a 64bit perl (/opt/perl64) build.


    Enjoy, Have FUN! H.Merijn