Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

XML::LibXML setup of library paths

by Anonymous Monk
on Nov 12, 2019 at 13:33 UTC ( #11108587=perlquestion: print w/replies, xml ) Need Help??

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

Dear Monks,

It could take a long time* to figure this out but I want to enjoy Hauke D's lovely Badge::Simple module right now! I guess my computer has a few versions of libxml2 cause it says this when failing to install XML::LibXML:

Failed test 'LIBXML__VERSION == LIBXML_RUNTIME_VERSION'...Your setup of library paths is incorrect! 

Please help me setup the library paths correctly:

cpanm -v Badge::Simple
...
==> Found dependencies: XML::LibXML
...
t/01basic.t ........................................ Warning: program compiled against libxml 209 using older 208
Warning: XML::LibXML compiled against libxml2 20904, but runtime libxml2 is older 20800
t/01basic.t ........................................ 1/3 
#   Failed test 'LIBXML__VERSION == LIBXML_RUNTIME_VERSION'
#   at t/01basic.t line 18.
#          got: '20904'
#     expected: '20800'
# DO NOT REPORT THIS FAILURE: Your setup of library paths is incorrect!
# 
# 
# Compiled against libxml2 version: 20904
# Running libxml2 version:          20800
brew info libxml2
libxml2: stable 2.9.9 (bottled), HEAD [keg-only]
GNOME XML library
http://xmlsoft.org/
/usr/local/Cellar/libxml2/2.9.4_2 (277 files, 10MB)
... Built from source on 2017-04-05 at 01:23:21

==> Caveats
libxml2 is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
* I tried to install a year ago when Badge::Simple was released but could not figure out my problem with libxml2 :-/

Thank you

Replies are listed 'Best First'.
Re: XML::LibXML setup of library paths
by choroba (Archbishop) on Nov 12, 2019 at 15:19 UTC
    libxml library is installed in version 2.9.4, but XML::LibXML compiles against 2.8.0, do you have the correct header/dev files installed?

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re: XML::LibXML setup of library paths
by jcb (Deacon) on Nov 13, 2019 at 04:22 UTC

    The problem is that you are on a Macintosh. Your version of MacOS X ships with libxml2 20800 and finds that first when loading libxml2, likely because it is already loaded somewhere in another process. Your failures here are due to the compiler finding version 20904, but the dynamic loader supplying 20800.

    There should be some way to get the system to actually load the newer version of libxml2 from a "keg" but that is your problem here — the compiler is using the new version, but the dynamic loader is using the older version that presumably Apple shipped.

      There should be some way to get the system to actually load the newer version of libxml2 from a "keg"

      Thank you for explaining the situation. I barely grasp the problem, let alone the solution. I find people on other sites fixing similar sounding issues with the command:

      brew link --force libxml2
      
      I tried it to see what happens:
      brew link --dry-run libxml2
      Would link:
      /usr/local/bin/xml2-config
      /usr/local/bin/xmlcatalog
      /usr/local/bin/xmllint
      /usr/local/include/libxml2
      /usr/local/share/aclocal/libxml.m4
      /usr/local/share/doc/libxml2-2.9.7
      /usr/local/share/gtk-doc/html/libxml2
      /usr/local/share/man/man1/xml2-config.1
      /usr/local/share/man/man1/xmlcatalog.1
      /usr/local/share/man/man1/xmllint.1
      /usr/local/share/man/man3/libxml.3
      /usr/local/lib/cmake/libxml2
      /usr/local/lib/libxml2.2.dylib
      /usr/local/lib/libxml2.a
      /usr/local/lib/libxml2.dylib
      /usr/local/lib/pkgconfig/libxml-2.0.pc
      /usr/local/lib/python2.7/site-packages/drv_libxml2.py
      /usr/local/lib/python2.7/site-packages/libxml2.py
      /usr/local/lib/python2.7/site-packages/libxml2_python-2.9.7-py2.7.egg-info
      /usr/local/lib/python2.7/site-packages/libxml2mod.so
      /usr/local/lib/xml2Conf.sh
      
      If you need to have this software first in your PATH instead consider running:
        echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.bash_profile
      
      /usr/local/include/libxml2 looks interesting because I don't have it and can't find those links when looking for some of them. But I do have /usr/bin/xmllint already:
      xmllint --version
      xmllint: using libxml version 20904
      
      I don't know what forcing that link will do to the system, what it will break, how to unforce...
      I have 3 versions, cause the first 2 are identical, except for date (/opt is 2012 and /usr is 2018)
      locate xmlversion.h
      
      /opt/local/include/libxml2/libxml/xmlversion.h
      /usr/include/libxml2/libxml/xmlversion.h
      /usr/local/Cellar/libxml2/2.9.4_2/include/libxml2/libxml/xmlversion.h
      /usr/local/Cellar/libxml2/2.9.7/include/libxml2/libxml/xmlversion.h
      

        Those first two are the ancient version Apple ships as part of Mac OS X. I do not know how to get Mac OS X to actually load the newer versions. Maybe add the directory containing a "libxml" .dylib to LD_LIBRARY_PATH whenever running your new perl extension?

      The problem is that you are on a Macintosh.

      no thats not the problem

        >> The problem is that you are on a Macintosh.

        > no thats not the problem

        I have mixed feelings, mostly good, but saw this yesterday from cpan:

        Configuring BSD-Sysctl-0.11 ... OS unsupported (darwin). Here's a nickel, go buy yourself a real OS.

Re: XML::LibXML setup of library paths under perlbrew
by Anonymous Monk on Nov 13, 2019 at 11:35 UTC
    Hi.

    cpanm --look XML::LibXML

    edit Makefile.PL

    and replace this with your own paths  CCFLAGS => Alien::Libxml2->cflags . " $Config{ccflags}", LIBS => [ Alien::Libxml2->libs ],

    Once upon a time I used something like  perl Makefile.PL INC="-IC:\citrusperl\mingw\xminms\include -IC:\citrusperl\mingw\xminms\include\libxml2 " LIBS="-LC:\citrusperl\mingw\mingw32\lib -LC:\citrusperl\mingw\xminms\lib -lxslt -lxml2 -liconv -lws2_32 "

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2019-12-09 02:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?