Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Installing XML::Parser (with expat)

by dorko (Parson)
on Feb 13, 2007 at 17:49 UTC ( #599727=perlquestion: print w/ replies, xml ) Need Help??
dorko has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I'm not having much luck getting XML::Parser to work with expat. I've downloaded and installed expat version 2.0.0:

PATH=/usr/ccs/bin:$PATH # to add the correct "ar" PATH=/local/gnu/bin:$PATH # add gcc to the path so configure can fin +d it. ./configure --prefix=/home/reliant/shaw/.local /local/gnu/bin/make # run the right make -- the wrong make doe +sn't understand '-phony' /local/gnu/bin/make test /local/gnu/bin/make install
That seems to have went well, leaving the appropriate files in /home/reliant/shaw/.local

Next, firing up CPAN, I did a get XML::Parser. (PREFIX and LIB are correctly set in MyConfig.PM) I then edited the Makefile.PL to include:

$expat_libpath = '/home/reliant/shaw/.local/lib'; $expat_incpath = '/home/reliant/shaw/.local/include';

Back to CPAN, and make, test, and install seemed to have went well, leaving the various bits and pieces in the expected places.

So then I try and run a CGI script:

#!/usr/bin/perl use strict; use warnings; use CGI qw/:standard/; print header; use CGI::Carp qw(fatalsToBrowser); use lib ('/home/reliant/shaw/perlmodules'); use lib ('/home/reliant/shaw/perlmodules/sun4-solaris'); require XML::Simple; require XML::Parser;
and it results in:
Content-type: text/html Software error: Can't load '/home/reliant/shaw/perlmodules/sun4-solaris/auto/XML/Parse +r/Expat/Expat.so' for module XML::Parser::Expat: ld.so.1: perl: fatal +: libgcc_s.so.1: open failed: No such file or directory at /usr/local +/lib/perl5/5.8.0/sun4-solaris/DynaLoader.pm line 229. at /home/reliant/shaw/perlmodules/sun4-solaris/XML/Parser.pm line 14 Compilation failed in require at /home/reliant/shaw/perlmodules/sun4-s +olaris/XML/Parser.pm line 14. BEGIN failed--compilation aborted at /home/reliant/shaw/perlmodules/su +n4-solaris/XML/Parser.pm line 18. For help, please send mail to the webmaster (webct@reliant.ucf.edu), g +iving this error message and the time and date of the error. Content-type: text/html Software error: [Tue Feb 13 12:17:07 2007] brenttest.pl: Can't load '/home/reliant/sha +w/perlmodules/sun4-solaris/auto/XML/Parser/Expat/Expat.so' for module + XML::Parser::Expat: ld.so.1: perl: fatal: libgcc_s.so.1: open failed +: No such file or directory at /usr/local/lib/perl5/5.8.0/sun4-solari +s/DynaLoader.pm line 229. [Tue Feb 13 12:17:07 2007] brenttest.pl: at /home/reliant/shaw/perlmo +dules/sun4-solaris/XML/Parser.pm line 14 [Tue Feb 13 12:17:07 2007] brenttest.pl: Compilation failed in require + at /home/reliant/shaw/perlmodules/sun4-solaris/XML/Parser.pm line 14 +. [Tue Feb 13 12:17:07 2007] brenttest.pl: BEGIN failed--compilation abo +rted at /home/reliant/shaw/perlmodules/sun4-solaris/XML/Parser.pm lin +e 18. Compilation failed in require at /webct/webct-3.6.0.18/webct/webct/gen +eric/admin/brenttest.pl line 12. For help, please send mail to the webmaster, giving this error message + and the time and date of the error.
Well, I beg do to differ because I've verified that /home/reliant/shaw/perlmodules/sun4-solaris/auto/XML/Parser/Expat/Expat.so exists, and is readable and executable by everyone.

Any thoughts, questions, comments or suggestions as to what I'm not doing right?

UPDATE: I should add I'm trying to do this on Solaris.

Cheers,

Brent

-- Yeah, I'm a Delt.

Comment on Installing XML::Parser (with expat)
Select or Download Code
Re: Installing XML::Parser (with expat)
by derby (Abbot) on Feb 13, 2007 at 18:57 UTC

    Your Expat.so depends on external libraries (libexpat.so). Do an

    ldd /home/reliant/shaw/perlmodules/sun4-solaris/auto/XML/Parser/Expat/Expat.so

    to see what libraries your version is dependent upon. You then either need to update your LD_LIBRARY_PATH to include the libexpat.so directory (or update whatever conf file Solaris uses to control library loading - on linux it's /etc/ld.so.conf).

    -derby
      derby,

      I appreciate your help. I think I've done what you've suggested.

      ldd /home/reliant/shaw/perlmodules/sun4-solaris/auto/XML/Parser/Expat/ +Expat.so libexpat.so.1 => /home/reliant/shaw/.local/lib/libexpa +t.so.1 libc.so.1 => /usr/lib/libc.so.1 libgcc_s.so.1 => /local/gnu/lib//libgcc_s.so.1 libdl.so.1 => /usr/lib/libdl.so.1 /usr/platform/SUNW,Ultra-80/lib/libc_psr.so.1

      So I modified my script to add /local/gnu/lib, /home/reliant/shaw/.local/lib, /usr/lib and /usr/platform/SUNW,Ultra-80/lib to the LD_LIBRARY_PATH environment variable. The new script reads:

      #!/usr/bin/perl use strict; use warnings; use CGI qw/:standard/; print header; use CGI::Carp qw(fatalsToBrowser); print `LD_LIBRARY_PATH="/local/gnu/lib/:/local/lib/:\$LD_LIBRARY_PATH" +`; print `EXPORT LD_LIBRARY_PATH`; use lib ('/home/reliant/shaw/perlmodules'); use lib ('/home/reliant/shaw/perlmodules/sun4-solaris'); print "<pre>"; use Data::Dumper; print Dumper \%ENV; $ENV{'LD_LIBRARY_PATH'} .= ':/local/gnu/lib:/home/reliant/shaw/.local/ +lib:/usr/lib:/usr/platform/SUNW,Ultra-80/lib'; print `env`; require XML::Simple; require XML::Parser;

      It's output is:

      $VAR1 = { 'SCRIPT_NAME' => '/webct/admin/brenttest.pl', 'SERVER_NAME' => 'webct2.ucf.edu', 'SERVER_ADMIN' => 'webct@reliant.ucf.edu', 'HTTP_ACCEPT_ENCODING' => 'gzip,deflate', 'LD_LIBRARY_PATH' => '/webct/webct-3.6.0.18/webct/webct/gene +ric/bin', 'HTTP_CONNECTION' => 'keep-alive', 'REQUEST_METHOD' => 'GET', 'HTTP_ACCEPT' => 'text/xml,application/xml,application/xhtml ++xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'SCRIPT_FILENAME' => '/webct/webct-3.6.0.18/webct/webct/gene +ric/admin/brenttest.pl', 'SERVER_SOFTWARE' => 'Apache/2.0.52 (Unix) mod_jk/1.2.6 DAV/ +2', 'webct_root' => '/webct/webct-3.6.0.18/webct', 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'REMOTE_USER' => 'admin', 'AUTH_TYPE' => 'Basic', 'TZ' => 'US/Eastern', 'QUERY_STRING' => '', 'REMOTE_PORT' => '2149', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows; U; Windows NT 5. +1; en-US; rv:1.8.0.9) Gecko/20061206 Firefox/1.5.0.9', 'SERVER_PORT' => '8900', 'SERVER_SIGNATURE' => ' Apache/2.0.52 (Unix) mod_jk/1.2.6 DAV/2 Server at webct2.ucf.edu Port +8900 ', 'HTTP_CACHE_CONTROL' => 'max-age=0', 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5', 'HTTP_COOKIE' => 'https%3a%2f%2fmy.ucf.edu%2fpsp%2fpaprod%2f +employee%2fempl%2frefresh=list: %3ftab%3dmypage2|%3ftab%3dmypage3|||| +||; SignOnDefault=b0111614; net107-80-PORTAL-PSJSESSIONID=FQfvcFGmJWD +PGqLT3QhzW7mQQFcp2f7k!-877246909; FIN6-80-PORTAL-PSJSESSIONID=FQfvyyb +gR9YdJBBpX01VNYRvBV2crSWr!-698869452', 'REMOTE_ADDR' => '10.173.87.94', 'HTTP_KEEP_ALIVE' => '300', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'PATH' => '/webct/webct-3.6.0.18/webct/jre/bin:/bin:/usr/bin +:/usr/ucb:/usr/bin/X11:/usr/local/bin:/usr/local/bin', 'REQUEST_URI' => '/webct/admin/brenttest.pl', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SERVER_ADDR' => '132.170.240.141', 'DOCUMENT_ROOT' => '/webct/webct-3.6.0.18/webct/user', 'HTTP_HOST' => 'reliant.ucf.edu:8900' }; TZ=US/Eastern webct_root=/webct/webct-3.6.0.18/webct LD_LIBRARY_PATH=/webct/webct-3.6.0.18/webct/webct/generic/bin:/local/g +nu/lib:/home/reliant/shaw/.local/lib:/usr/lib:/usr/platform/SUNW,Ultr +a-80/lib HTTP_HOST=reliant.ucf.edu:8900 HTTP_USER_AGENT=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8 +.0.9) Gecko/20061206 Firefox/1.5.0.9 HTTP_ACCEPT=text/xml,application/xml,application/xhtml+xml,text/html;q +=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 HTTP_ACCEPT_LANGUAGE=en-us,en;q=0.5 HTTP_ACCEPT_ENCODING=gzip,deflate HTTP_ACCEPT_CHARSET=ISO-8859-1,utf-8;q=0.7,*;q=0.7 HTTP_KEEP_ALIVE=300 HTTP_CONNECTION=keep-alive HTTP_COOKIE=https%3a%2f%2fmy.ucf.edu%2fpsp%2fpaprod%2femployee%2fempl% +2frefresh=list: %3ftab%3dmypage2|%3ftab%3dmypage3||||||; SignOnDefaul +t=b0111614; net107-80-PORTAL-PSJSESSIONID=FQfvcFGmJWDPGqLT3QhzW7mQQFc +p2f7k!-877246909; FIN6-80-PORTAL-PSJSESSIONID=FQfvyybgR9YdJBBpX01VNYR +vBV2crSWr!-698869452 HTTP_CACHE_CONTROL=max-age=0 PATH=/webct/webct-3.6.0.18/webct/jre/bin:/bin:/usr/bin:/usr/ucb:/usr/b +in/X11:/usr/local/bin:/usr/local/bin SERVER_SIGNATURE= Apache/2.0.52 (Unix) mod_jk/1.2.6 DAV/2 Server at webct2.ucf.edu Port +8900 SERVER_SOFTWARE=Apache/2.0.52 (Unix) mod_jk/1.2.6 DAV/2 SERVER_NAME=webct2.ucf.edu SERVER_ADDR=132.170.240.141 SERVER_PORT=8900 REMOTE_ADDR=10.173.87.94 DOCUMENT_ROOT=/webct/webct-3.6.0.18/webct/user SERVER_ADMIN=webct@reliant.ucf.edu SCRIPT_FILENAME=/webct/webct-3.6.0.18/webct/webct/generic/admin/brentt +est.pl REMOTE_PORT=2149 REMOTE_USER=admin AUTH_TYPE=Basic GATEWAY_INTERFACE=CGI/1.1 SERVER_PROTOCOL=HTTP/1.1 REQUEST_METHOD=GET QUERY_STRING= REQUEST_URI=/webct/admin/brenttest.pl SCRIPT_NAME=/webct/admin/brenttest.pl Content-type: text/html Software error: Can't load '/home/reliant/shaw/perlmodules/sun4-solaris/auto/XML/Parse +r/Expat/Expat.so' for module XML::Parser::Expat: ld.so.1: perl: fatal +: libgcc_s.so.1: open failed: No such file or directory at /usr/local +/lib/perl5/5.8.0/sun4-solaris/DynaLoader.pm line 229. at /home/reliant/shaw/perlmodules/sun4-solaris/XML/Parser.pm line 14 Compilation failed in require at /home/reliant/shaw/perlmodules/sun4-s +olaris/XML/Parser.pm line 14. BEGIN failed--compilation aborted at /home/reliant/shaw/perlmodules/su +n4-solaris/XML/Parser.pm line 18. For help, please send mail to the webmaster (webct@reliant.ucf.edu), g +iving this error message and the time and date of the error. Content-type: text/html Software error: [Tue Feb 13 16:57:21 2007] brenttest.pl: Can't load '/home/reliant/sha +w/perlmodules/sun4-solaris/auto/XML/Parser/Expat/Expat.so' for module + XML::Parser::Expat: ld.so.1: perl: fatal: libgcc_s.so.1: open failed +: No such file or directory at /usr/local/lib/perl5/5.8.0/sun4-solari +s/DynaLoader.pm line 229. [Tue Feb 13 16:57:21 2007] brenttest.pl: at /home/reliant/shaw/perlmo +dules/sun4-solaris/XML/Parser.pm line 14 [Tue Feb 13 16:57:21 2007] brenttest.pl: Compilation failed in require + at /home/reliant/shaw/perlmodules/sun4-solaris/XML/Parser.pm line 14 +. [Tue Feb 13 16:57:21 2007] brenttest.pl: BEGIN failed--compilation abo +rted at /home/reliant/shaw/perlmodules/sun4-solaris/XML/Parser.pm lin +e 18. Compilation failed in require at /webct/webct-3.6.0.18/webct/webct/gen +eric/admin/brenttest.pl line 21. For help, please send mail to the webmaster, giving this error message + and the time and date of the error.

      It looks like the environment variable LD_LIBRARY_PATH is being updated with the new directories, but it's not having any impact.

      Anyone else have any suggestions?

      Cheers,

      Brent

      -- Yeah, I'm a Delt.
        Do ldd from CGI then compare

        print `LD_LIBRARY_PATH="/local/gnu/lib/:/local/lib/:\$LD_LIBRARY_PATH" +`; print `EXPORT LD_LIBRARY_PATH`;

        That's not going to work. That will set the environment var in your subshell but when you return from the backtick call the variable will be gone. See programatically setting the LD_LIBRARY_PATH (especially the comment from tye)

        -derby
Re: Installing XML::Parser (with expat)
by syphilis (Canon) on Feb 14, 2007 at 10:34 UTC
    ./configure --prefix=/home/reliant/shaw/.local

    Sometimes it's easier to just build a static library:
    ./configure --enable-static --disable-shared --prefix=/home/reliant/sh +aw/.local
    Of course, it shouldn't be necessary to do that. But it can save some aggravation :-)

    You still set $expat_libpath and $expat_incpath the same as you've already done ... and it should work ok. Worked fine for me on Windows - only problem was that I had to copy lib/expat.h and lib/expat_external.h to the tests folder to get 'make check' to run successfully when building expat-2.0.0.

    Cheers,
    Rob

      Weirdly enough, the --enable-static trick did not work out for me, but for completeness (and off-site backup :) ), here is what I need to do to build expat and XML::Parser on Solaris x86 with the SUN C compiler:

      First build expat:

      PATH=/usr/ccs/bin:$PATH # to add the correct "ar" # autotools does not seem to know when the configuration was changed, +this is just a safety measure gmake clean CC=/opt/SUNWspro/bin/cc CFLAGS="-KPIC -O -D_LARGEFILE_SOURCE -D_FILE_O +FFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -xarch=generic64" ./configure - +-prefix=/home/corion/lib --enable-shared gmake all # this one might not compile the C++ checks, if you don't have the SUN + C++ compiler installed gmake check gmake install

      After installation, remember to update LD_LIBRARY_PATH in an appropriate location:

      # Update LD_LIBRARY_PATH export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/corion/lib

      Then, the installation of XML::Parser works, although the SUN C compiler did not like having the library directories listed after the -lexpat command. So I had to fudge that by patching the Makefile.PL:

      unless ( check_lib( # fill in what you prompted the user for here #lib => [qw(expat)], header => ['expat.h'], debug => 1, incpath => $expat_incpath, # Ugly hack here ($expat_libpath? (libpath => "$expat_libpath -lexpat"):()), )) {

      Then, configuring and testing Just Works:

      perl Makefile.PL EXPATLIBPATH=/home/corion/lib/lib EXPATINCPATH=/home/ +corion/lib/include -lexpat gmake gmake test gmake install
Re: Installing XML::Parser (with expat)
by dorko (Parson) on Feb 14, 2007 at 19:15 UTC
    Just to bring this node to an end, I thought I'd mention that I got a static copy of expat installed using Rob's ./configure --enable-static --disable-shared --prefix=/home/reliant/shaw/.local suggestion.

    Then I reinstalled XML::Parser as before, and it worked. At that point, I replaced the (linked) Expat.so file on the production server with the (static) Expat.so file from the development server I was working on.

    A special thanks to Derby for pointing me in the right direction with ldd and LD_LIBRARY_PATH. He was correct about my LD_LIBRARY_PATH being out of whack. I'm sure the suggestions to fix my LD_LIBRARY_PATH would have worked, but it was easier for me to replace the Expat.so with a staticly compiled copy.

    Cheers,

    Brent

    -- Yeah, I'm a Delt.
Re: Installing XML::Parser (with expat)
by Anonymous Monk on Dec 18, 2009 at 20:48 UTC
    Thank you, derby. I patched LD_LIBRARY_PATH!! I succedeed to run configure_etc.sh, for my openca configuration. Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://599727]
Approved by Joost
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2014-09-20 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls