shlomif / perl-XML-LibXML

The XML-LibXML CPAN Distribution for Processing XML using the libxml2 library
https://metacpan.org/release/XML-LibXML
Other
17 stars 35 forks source link

Fatal error prevents XML::LibXML installation #61

Open nickforino opened 3 years ago

nickforino commented 3 years ago

Hi everyone,

My attempts to install XML::LibXML with cpanm and also manually fail, and return the following fatal error:

cc -c  -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector -Os   -DVERSION=\"2.0206\" -DXS_VERSION=\"2.0206\"  -iwithsysroot "/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE"  -DHAVE_UTF8 Av_CharPtrPtr.c
cc -c  -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector -Os   -DVERSION=\"2.0206\" -DXS_VERSION=\"2.0206\"  -iwithsysroot "/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE"  -DHAVE_UTF8 Devel.c
Devel.xs:28:10: fatal error: 'libxml/xmlmemory.h' file not found
#include <libxml/xmlmemory.h>
         ^~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Devel.o] Error 1

After reading some similar issues I've ensured the dependent modules are properly installed (XML::SAX , XML:: NamespaceSupport) and that I've got a current version of libxml2 and Alien.

Any help would be greatly appreciated, please let me know any additional information you need to diagnose the issue and I'll respond promptly. Thanks!

plicease commented 3 years ago

Can you tell me what version of Alien::LibXML and Alien::Build you have installed, and if you can provide the log for its install?

plicease commented 3 years ago

Also make sure that you are running the tests when installing Alien::LibXML because it should fail if it detects the wrong flags.

nickforino commented 3 years ago

@plicease Thanks for your reply. Apparently I just had Alien, and not Alien::LibXML. Although I attempted to install Alien::LibXML via cpanm and this failed. I've attached the log, notably it throws the same error line when it fails:

 t/tree1.c:13:10: fatal error: 'libxml/parser.h' file not found
#include <libxml/parser.h>
         ^~~~~~~~~~~~~~~~~

build.log

plicease commented 3 years ago

@nickforino I apologize but the actual dependency is Alien::Libxml2 lol Can you try that one instead.

nickforino commented 3 years ago

@plicease no worries! My Alien::Libxml2 version is 0.17 and Alien::Build version is 2.37.

nickforino commented 3 years ago

@plicease I just tried to force reinstall Alien::Libxml2 and Alien::Build, I've attached the logs for both. The test and installation for Alien::Libxml2 failed, while Build installed without a hitch, I've attached the log for Libxml2. build.log

nickforino commented 3 years ago

It appears that when attempting make, my system is having a hard time finding my libxml2 installation (hence the fatal errors). I tried setting the following environmental path variables, but this also failed.

export PATH = /usr/local/opt/libxml2/bin
export LDFLAGS="-L/usr/local/opt/libxml2/lib"
export CPPFLAGS="-I/usr/local/opt/libxml2/include"
export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"
plicease commented 3 years ago

Looks like Alien::Libxml2 is looking in /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include (from xml2-config) for the header files, can you check if the appropriate files in there?

One work around, if you don't mind Alien::Libxml2 building the library for you is to force a share install:

env ALIEN_INSTALL_TYPE=share cpanm -v Alien::Libxml2
nickforino commented 3 years ago

Hi @plicease, apologies for the very late reply.

Regarding your last question: I believe the path Alien::Libxml2 is looking for headers in/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include is incorrect. The header files (namely, I found parser.h) several directories deeper in /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/libxml2/libxml/parser.h.

plicease commented 3 years ago

Regarding your last question: I believe the path Alien::Libxml2 is looking for headers in/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include is incorrect. The header files (namely, I found parser.h) several directories deeper in /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/libxml2/libxml/parser.h.

The include path would have come from either xml2-config --cflags or pkg-config --cflags libxml-2.0 can you see if either of those has the wrong path specified?

nickforino commented 3 years ago

Indeed, looks like the wrong paths are specified!

xml2-config --cflags returns -I/usr/local/Cellar/libxml2/2.9.10_2/include/libxml2 I believe the Cellar directory is from Homebrew, but I can't quite remember what I tried to install, as I was likely trying things out of desperation...regardless, this path does not directly lead to the headers, which are again several directories further in /usr/local/Cellar/libxml2/2.9.10_2/include/libxml2/libxml.

Similarly, pkg-config --cflags libxml-2.0 returns the same path: -I/usr/local/Cellar/libxml2/2.9.10_2/include/libxml2

Is the solution to uninstall Homebrew?