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

Hi There. I'm not sure exactly what issue I'm hitting, but I think when I try to install XML::LibXML, it's not finding my install of LibXML2. This is what I've tried

I installed "LibXML2" with Homebrew

brew install libxml2 Updating Homebrew... ==> Auto-updated Homebrew! Updated 1 tap (homebrew/core). ==> Updated Formulae Updated 19 formulae. Warning: libxml2 2.9.10_2 is already installed and up-to-date To reinstall 2.9.10_2, run `brew reinstall libxml2`

I added a link to that in the .bash_profile

# PATH PATH="/usr/local/Cellar/libxml2/2.9.10_2/bin:$PATH" export PATH

I then tried to install "XML::LibXML"

cpanm XML::LibXML --> Working on XML::LibXML Fetching http://www.cpan.org/authors/id/S/SH/SHLOMIF/XML-LibXML-2.0206 +.tar.gz ... OK Configuring XML-LibXML-2.0206 ... OK Building and testing XML-LibXML-2.0206 ... FAIL ! Installing XML::LibXML failed. See /Users/root/.cpanm/work/160710875 +5.33137/build.log for details. Retry with --force to force install it +.

I did try to force the install, and it installed, but the perl script I'm trying to run still came up with the same error, so I don't think it was successful

I checked the error log

Can't load '/Users/root/.cpanm/work/1607108755.33137/XML-LibXML-2.0206 +/blib/arch/auto/XML/LibXML/LibXML.bundle' for module XML::LibXML: dlo +pen(/Users/root/.cpanm/work/1607108755.33137/XML-LibXML-2.0206/blib/a +rch/auto/XML/LibXML/LibXML.bundle, 2): Symbol not found: _xmlFree Referenced from: /Users/root/.cpanm/work/1607108755.33137/XML-LibXML +-2.0206/blib/arch/auto/XML/LibXML/LibXML.bundle Expected in: flat namespace in /Users/root/.cpanm/work/1607108755.33137/XML-LibXML-2.0206/blib/ar +ch/auto/XML/LibXML/LibXML.bundle at /Users/root/perl5/perlbrew/perls/ +perl-5.28.2/lib/5.28.2/darwin-2level/DynaLoader.pm line 197. � at /Users/root/.cpanm/work/1607108755.33137/XML-LibXML-2.0206 +/blib/lib/XML/LibXML.pm line 156. BEGIN failed--compilation aborted at /Users/root/.cpanm/work/160710875 +5.33137/XML-LibXML-2.0206/blib/lib/XML/LibXML.pm line 156. Compilation failed in require at t/01basic.t line 6. BEGIN failed--compilation aborted at t/01basic.t line 6. # Looks like your test exited with 2 before it could output anything. t/01basic.t ........................................ Dubious, test returned 2 (wstat 512, 0x200) Failed 3/3 subtests Can't load '/Users/root/.cpanm/work/1607108755.33137/XML-LibXML-2.0206 +/blib/arch/auto/XML/LibXML/LibXML.bundle' for module XML::LibXML: dlo +pen(/Users/root/.cpanm/work/1607108755.33137/XML-LibXML-2.0206/blib/a +rch/auto/XML/LibXML/LibXML.bundle, 2): Symbol not found: _xmlFree Referenced from: /Users/root/.cpanm/work/1607108755.33137/XML-LibXML +-2.0206/blib/arch/auto/XML/LibXML/LibXML.bundle Expected in: flat namespace in /Users/root/.cpanm/work/1607108755.33137/XML-LibXML-2.0206/blib/ar +ch/auto/XML/LibXML/LibXML.bundle at /Users/root/perl5/perlbrew/perls/ +perl-5.28.2/lib/5.28.2/darwin-2level/DynaLoader.pm line 197. � at /Users/root/.cpanm/work/1607108755.33137/XML-LibXML-2.0206 +/blib/lib/XML/LibXML.pm line 156. BEGIN failed--compilation aborted at /Users/root/.cpanm/work/160710875 +5.33137/XML-LibXML-2.0206/blib/lib/XML/LibXML.pm line 156. Compilation failed in require at /Users/root/.cpanm/work/1607108755.33 +137/XML-LibXML-2.0206/blib/lib/XML/LibXML/Common.pm line 29. BEGIN failed--compilation aborted at /Users/root/.cpanm/work/160710875 +5.33137/XML-LibXML-2.0206/blib/lib/XML/LibXML/Common.pm line 29. Compilation failed in require at t/02parse.t line 20. BEGIN failed--compilation aborted at t/02parse.t line 20. # Looks like your test exited with 2 before it could output anything. t/02parse.t ........................................ Dubious, test returned 2 (wstat 512, 0x200) Failed 533/533 subtests

It goes on like this for about 3 miles

Has anyone seen this before, and have any thoughts and theories? Please let me know if you need more info. Thanks in advance, your help is much appreciated.

Replies are listed 'Best First'.
Re: XML::LibXML fails install on macOS Big Sur
by syphilis (Archbishop) on Dec 04, 2020 at 23:24 UTC
    Symbol not found: _xmlFree

    That's the killer right there.
    LibXML.xs calls xmlFree(), expecting that function to be resolved by your libxml2 library, but it's not.

    Either your libxml2 library does not contain that expected functionality (which I think is unlikely), or your libxml2 library is simply not being located and loaded at runtime.
    I don't know exactly what would be required to fix this on your system.
    I think that, in building XML::LibXML-2.0206, there are some pre-tests run to check that libxml2 is available - so it's a bit odd that this problem is not detected at the beginning of the build.
    Perhaps those pre-build checks don't extend to verifying that the libxml2 dynamic library is going to be found when needed at runtime ... I don't know.

    I did try to force the install, and it installed, but the perl script I'm trying to run still came up with the same error, so I don't think it was successful

    Well ... it installed successfully ... but the underlying problem of the failure to resolve _xmlFree at runtime has not been addressed.

    Cheers,
    Rob
Re:XML::LibXML fails install on macOS Big Sur
by wazat (Monk) on Dec 05, 2020 at 16:45 UTC

    I don't think PATH affects search for .so files

    # PATH PATH="/usr/local/Cellar/libxml2/2.9.10_2/bin:$PATH" export PATH

    It's been a long while since I've had to deal with something like this but you might try LD_LIBRARY_PATH. Assuming libxml2.so.2 is located in /usr/local/Cellar/libxml2/2.9.10_2/bin, you could try

    LD_LIBRARY_PATH=/usr/local/Cellar/libxml2/2.9.10_2/bin cpanm XML::LibX +ML

        LD_LIBRARY_PATH may be bad, but its use to investigate if there is a problem locating libxml is less so.

        I'm quite rusty at this sort of thing. Perhaps you can provide quidance to the original poster.

Re: XML::LibXML fails install on macOS Big Sur
by Anonymous Monk on Dec 15, 2020 at 00:08 UTC

      Hi,

      this is my first post ;-)

      I'm a reader for nearly 20 years now, perhaps i can help today ;-)

      Anyhow, the problem originates from the fact, that BigSur provides a native

      XML Library and therefore the cc compiler will always favor the local libxml which differs from the version homebrew is providing.

      homebrew version: '20904'

      Big sur version: '20910'

      How you can get it working: (Assuming you have perl-5.3.32 homebrew package installed)

      1.) install the gcc homebrew package !

      2.) Extract the source

      3.) perl Makefile.PL

      4.) Edit the Makefile

      Change these lines:

      Change the CC binary

       CC = gcc

      Change the LD binary

       LD = gcc

      Change the LDDFLAGS to:

      LDDLFLAGS = -L/usr/local/opt/libxml2/lib -L/usr/local/lib/perl5/5.32.0 +/darwin-thread-multi-2level/CORE -mmacosx-version-min=10.15 -bundle - +fstack-protector- strong -lxml2 -lperl

      Change the LDFLAGS to

      LDFLAGS = -L/usr/local/opt/libxml2/lib -L/usr/local/lib/perl5/5.32.0/darwin-thread-multi-2level/CORE -mmacosx-version-min=10.15 -fstack-protector-strong -lxml2 -lperl

      Change the INC Path to

      INC = -I/usr/local/opt/libxml2/include

      Change the PASSTHROUGH INC

      PASTHRU_INC='-I/usr/local/opt/libxml2/include $(PASTHRU_INC)'

      Then build:

      make

      Check using otool:

      $otool -L blib/arch/auto/XML/LibXML/LibXML.bundle blib/arch/auto/XML/LibXML/LibXML.bundle: /usr/local/opt/libxml2/lib/libxml2.2.dylib (compatibility version +12.0.0, current version 12.10.0) /usr/local/opt/perl/lib/perl5/5.32.0/darwin-thread-multi-2level/CO +RE/libperl.dylib (compatibility version 5.32.0, current version 5.32. +0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current v +ersion 1292.60.1) /usr/local/lib/gcc/10/libgcc_s.1.dylib (compatibility version 1.0. +0, current version 1.0.0)
      make test

      (3 tests will fail because the tests favor the native libs, so don't mind

       make install

      Best regards

      Franz

        Welcome to the Monastery!

        This is rather impressive for a first post. Great job, and nice to have you aboard!