Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Cannot build/install XML::Parser

by nixcat (Initiate)
on Mar 13, 2023 at 16:21 UTC ( #11150955=perlquestion: print w/replies, xml ) Need Help??

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

I'm trying to install XML::Parser in RHEL8 Linux and have both OS RPM packages 'expat' and 'expat-devel' installed. I also have a successful expat Perl module installation running:

cpanm XML::Parser::Expat

XML::Parser::Expat is up to date. (2.46)

I'm running cpanm XML::Parser and getting:

Expat must be installed prior to building XML::Parser and I can't find it in the standard library directories.

I also tried specifying these:

EXPATLIBPATH=... To set the directory in which to find libexpat

EXPATINCPATH=... To set the directory in which to find expat.h

And running

perl Makefile.PL EXPATLIBPATH=/usr/lib EXPATINCPATH=/usr/include

but with no difference. Any suggestions?

Replies are listed 'Best First'.
Re: Cannot build/install XML::Parser
by hippo (Bishop) on Mar 13, 2023 at 17:14 UTC

    How did you manage to install XML::Parser::Expat without XML::Parser? The former is in the dist of the latter.

    Suggestion: Install from the RHEL repo using dnf instead?

    Available Packages perl-XML-Parser.x86_64 2.44-11.el8 + rhel-8-for-x86_64-appstream-rpms


      Hi there - thanks for the reply. Because I don't have root access on this server all the Perl modules have been installed in a subdir of a user that owns all the files for the application (like a service account). These are the settings in the .bashrc for that user in question that were configured when I ran cpan with a -o to configure:

      PATH="/home/user/perl5/bin${PATH:+:${PATH}}"; export PATH; PERL5LIB="/home/user/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export + PERL5LIB; PERL_LOCAL_LIB_ROOT="/home/user/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LO +CAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT; PERL_MB_OPT="--install_base \"/home/user/perl5\""; export PERL_MB_OPT; PERL_MM_OPT="INSTALL_BASE=/home/user/perl5"; export PERL_MM_OPT;

      All modules were installed from scratch using cpanm. And to your point about XML::Parser::XPAT - that's what I'm puzzled about. It installed just fine. So I don't understand why the Parser would fail.

        Looking at their respective Makefile.PL, X::P calls check_lib of Devel::CheckLib to find/verify the expat lib. But X::P::E just assumes that the library is there and links with -lexpat. And if it is there, as you said, then no problem. So the failure is most likely with check_lib of Devel::CheckLib. You could write a minimal script using said sub to see if it fails and how:

        use Devel::CheckLib; $expat_libpath = $ENV{EXPATLIBPATH} || ''; $expat_incpath = $ENV{EXPATINCPATH} || ''; my @replacement_args; foreach (@ARGV) { if (/^EXPAT(LIB|INC)PATH=(.+)/) { if ( $1 eq 'LIB' ) { $expat_libpath = $2; } else { $expat_incpath = $2; } #push(@replacement_args, "$1=$2"); } else { push( @replacement_args, $_ ); } } @ARGV = @replacement_args; # ** I am using check_lib_or_exit() for verbosity check_lib_or_exit( # fill in what you prompted the user for here lib => [qw(expat)], header => ['expat.h'], incpath => $expat_incpath, ( $expat_libpath ? ( libpath => $expat_libpath ) : () ), );

        You could also hack Devel::CheckLib (since you own it) to make it more verbose and pinpoint exactly where the problem is.

        The absolute shortcut is to hack X::P's Makefile.PL to not exit 0 when it thinks that expat libraries/headers can not be found (according to CheckLib), and see if it will be linked eventually (since it is located in /usr/lib it will need no extra CFLAGS/LDFLAGS).

        But you must make sure that the library is there and its header files too.

        bw, bliako

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11150955]
Approved by LanX
Front-paged by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2023-03-22 02:28 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (60 votes). Check out past polls.