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

Hi,

I'm trying to install XML::Parser on one of my machines (solaris) and it's having a problem locating the library expat (libexpat.so). This library is in a non standard place (not /usr/lib) and although I have set up LD_LIBRARY_PATH, building XML::Parser still cannot see the library.

I had a look to see why it couldn't locate it and Makefile.PL is using Ext::Liblist to locate libraries. However, from what I can determine, Ext::Liblist seems to only locate libraries that the perl binary knows about. This seems to be a bit unusual (or inflexible) but I've tried to set various options listed in it's manual (which seems to be a bit terse on this information).

So my question is, can it be done and if so, how?

Thanks.

Fairchild.
  • Comment on How to get Ext::Liblist to recognise different library paths?

Replies are listed 'Best First'.
Re: How to get Ext::Liblist to recognise different library paths?
by Anonymous Monk on Dec 10, 2009 at 09:27 UTC
      To elaborate a little ... during the Makefile.PL stage you should see a message that tells you to start the build process with perl Makefile.PL EXPATLIBPATH=/home/me/lib EXPATINCPATH=/home/me/include when libexpat is not found. (This is assuming that libexpat is in /home/me/lib and expat.h is in /home/me/include ... modify as necessary.)

      I personally prefer to take a different approach with the appalling Makefile.PL that ships with the XML::Parser source distro - I simply replace it with a Makefile.PL that contains:
      use ExtUtils::MakeMaker; WriteMakefile( NAME => 'XML::Parser', VERSION_FROM => 'Parser.pm', PREREQ_PM => { LWP => 0, #for tests } );
      If the expat library is in a location that EU::MM finds by default, then it's just a matter of starting with perl Makefile.PL.
      Otherwise, we have to run perl Makefile.PL LIBS=-L/home/me/lib INC=-I/home/me/include (again, modify those paths as necessary).

      Why the author insists on putting so much unnecessary crud (that doesn't even work properly !) into his Makefile.PL is completely and utterly beyond my comprehension.

      Cheers,
      Rob

      Update: I think I was mistaken about my simplified Makefile.PL working when libexpat is not found by default. (I think some other modifications to either the top level Makefile.PL or Expat/Makefile.PL are also needed.)
      Probably simplest to just use the original Makefile.PL and go with the EXPATINCPATH/EXPATLIBPATH kludge when libexpat is not found by default.
Re: How to get Ext::Liblist to recognise different library paths?
by desemondo (Hermit) on Dec 10, 2009 at 09:26 UTC
    hmm, what point does it fail / how far does it get?

    Have you tried fudging the install by inserting the path of libexpat.so into your PATH environment variable?

    or adding a begin block at the very top of the build script?

    eg.
    BEGIN { my $custom_lib_path = './blah/blah/etc'; push @INC, $custom_lib_path; }
      Hi,

      It fails at the starting point. That is, perl Makefile.PL. It barfs becauses it cant locate libexpat.so. If Ext::Liblist followed LD_LIBRARY_PATH then it would see it.

      The suggestion about using a soft link would probably solve the problem but I dont have root on that particular machine.

      I was aware about the suggestion about using the environment variable EXT... although the same documentation indicated that using LD_LIBRARY_PATH could resolve the problem as well.

      I did read the various documentation, searched the web, tried setting various environment variables on different platforms, etc.

      In summary, if there is no other way then I will use the environment variable mentioned above. I guess I am just abit surprised that something like Ext::Liblist isnt very flexible (i.e. can't search LD_LIBRARY_PATH or a similar type of environment variable) - since it's such a standard package of perl and perl being a very flexible swiss army knife.

      Fairchild.
Re: How to get Ext::Liblist to recognise different library paths?
by stefbv (Priest) on Dec 10, 2009 at 09:47 UTC
    Try to create a simbolic link:
    ln -s /path/to/libexpat.so /usr/lib/libexpat.so
    Update: if you have permisions.