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

In Mac OS X (snow leopard) have libxml2 installed in /usr/local and I'm trying to install XML::LibXML, but for some reason the Makefile can't find it. I need some help. Here is the output when I run Makefile.PL.
perl Makefile.PL LIBS='-L/usr/local/lib -lxml2 -lz -lpthread -liconv - +lm' INC='-I/usr/local/include/libxml2' Set up build environment without MacOSX10.4u SDK (will build native bi +naries) enable native perl UTF8 looking for -lxml2... no looking for -llibxml2... no libxml2 not found Try setting LIBS and INC values on the command line Or get libxml2 from http://xmlsoft.org/ If you install via RPMs, make sure you also install the -devel RPMs, as this is where the headers (.h files) are.
So I ran with DEBUG turned on & here is what I see:
perl Makefile.PL LIBS='-L/usr/local/lib -lxml2 -lz -lpthread -liconv - +lm' INC='-I/usr/local/include/libxml2' DEBUG=1 Set up build environment without MacOSX10.4u SDK (will build native bi +naries) enable native perl UTF8 looking for -lxml2... perl Makefile.PL 'INC=-I/usr/local/include/libxm +l2' 'LIBS=-L/usr/local/lib -lxml2 -lz -lpthread -liconv -lm' 'DEFINE= + -DHAVE_UTF8' Set up build environment without MacOSX10.4u SDK (will build native bi +naries) INC = -I/usr/local/include/libxml2 LIBS = -L/usr/local/lib -lxml2 -lz -lpthread -liconv -lm DEFINE = -DHAVE_UTF8 Writing Makefile for Conftest make test 'OTHERLDFLAGS=' cp Conftest.pm blib/lib/Conftest.pm /usr/local/ActivePerl-5.10/bin/perl /usr/local/ActivePerl-5.10/lib/Ext +Utils/xsubpp -typemap /usr/local/ActivePerl-5.10/lib/ExtUtils/typema +p Conftest.xs > Conftest.xsc && mv Conftest.xsc Conftest.c gcc -c -I/usr/local/include/libxml2 -fno-common -DPERL_DARWIN -DUSE_S +ITECUSTOMIZE -fno-merge-constants -DPRIVLIB_LAST_IN_INC -fno-strict-a +liasing -pipe -O3 -DVERSION=\"1\" -DXS_VERSION=\"1\" "-I/usr/local +/ActivePerl-5.10/lib/CORE" -DHAVE_UTF8 Conftest.c Running Mkbootstrap for Conftest () chmod 644 Conftest.bs rm -f blib/arch/auto/Conftest/Conftest.bundle LD_RUN_PATH="/usr/local/lib:/usr/lib" env MACOSX_DEPLOYMENT_TARGET=10. +3 cc -bundle -undefined dynamic_lookup -Wl,-search_paths_first Conft +est.o -o blib/arch/auto/Conftest/Conftest.bundle \ -L/usr/local/lib -lxml2 -lz -lpthread -liconv -lm \ ld: warning: in /usr/local/lib/libiconv.dylib, missing required archit +ecture x86_64 in file chmod 755 blib/arch/auto/Conftest/Conftest.bundle cp Conftest.bs blib/arch/auto/Conftest/Conftest.bs chmod 644 blib/arch/auto/Conftest/Conftest.bs PERL_DL_NONLAZY=1 /usr/local/ActivePerl-5.10/bin/perl "-Iblib/lib" "-I +blib/arch" test.pl 1..1 # Running under perl version 5.010000 for darwin # Current time local: Wed Jan 26 19:57:39 2011 # Current time GMT: Thu Jan 27 03:57:39 2011 # Using Test.pm version 1.25 Can't load 'blib/arch/auto/Conftest/Conftest.bundle' for module Confte +st: dlopen(blib/arch/auto/Conftest/Conftest.bundle, 2): no suitable i +mage found. Did find: blib/arch/auto/Conftest/Conftest.bundle: mach-o, but wrong archite +cture at /usr/local/ActivePerl-5.10/lib/DynaLoader.pm line 206. at test.pl line 2 Compilation failed in require at test.pl line 2. BEGIN failed--compilation aborted at test.pl line 2. not ok 1 # Failed test 1 in test.pl at line 1 # test.pl line 1 is: use Test; BEGIN { plan tests => 1; } END { ok($l +oaded) } make: *** [test_dynamic] Error 2 system call to 'make test 'OTHERLDFLAGS='' failed at Makefile.PL line +470. no looking for -llibxml2... perl Makefile.PL 'INC=-I/usr/local/include/li +bxml2' 'LIBS=-L/usr/local/lib -lxml2 -lz -lpthread -liconv -lm' 'DEFI +NE= -DHAVE_UTF8' Set up build environment without MacOSX10.4u SDK (will build native bi +naries) INC = -I/usr/local/include/libxml2 LIBS = -L/usr/local/lib -lxml2 -lz -lpthread -liconv -lm DEFINE = -DHAVE_UTF8 Writing Makefile for Conftest make test 'OTHERLDFLAGS=' cp Conftest.pm blib/lib/Conftest.pm /usr/local/ActivePerl-5.10/bin/perl /usr/local/ActivePerl-5.10/lib/Ext +Utils/xsubpp -typemap /usr/local/ActivePerl-5.10/lib/ExtUtils/typema +p Conftest.xs > Conftest.xsc && mv Conftest.xsc Conftest.c gcc -c -I/usr/local/include/libxml2 -fno-common -DPERL_DARWIN -DUSE_S +ITECUSTOMIZE -fno-merge-constants -DPRIVLIB_LAST_IN_INC -fno-strict-a +liasing -pipe -O3 -DVERSION=\"1\" -DXS_VERSION=\"1\" "-I/usr/local +/ActivePerl-5.10/lib/CORE" -DHAVE_UTF8 Conftest.c Running Mkbootstrap for Conftest () chmod 644 Conftest.bs rm -f blib/arch/auto/Conftest/Conftest.bundle LD_RUN_PATH="/usr/local/lib:/usr/lib" env MACOSX_DEPLOYMENT_TARGET=10. +3 cc -bundle -undefined dynamic_lookup -Wl,-search_paths_first Conft +est.o -o blib/arch/auto/Conftest/Conftest.bundle \ -L/usr/local/lib -lxml2 -lz -lpthread -liconv -lm \ ld: warning: in /usr/local/lib/libiconv.dylib, missing required archit +ecture x86_64 in file chmod 755 blib/arch/auto/Conftest/Conftest.bundle cp Conftest.bs blib/arch/auto/Conftest/Conftest.bs chmod 644 blib/arch/auto/Conftest/Conftest.bs PERL_DL_NONLAZY=1 /usr/local/ActivePerl-5.10/bin/perl "-Iblib/lib" "-I +blib/arch" test.pl 1..1 # Running under perl version 5.010000 for darwin # Current time local: Wed Jan 26 19:57:40 2011 # Current time GMT: Thu Jan 27 03:57:40 2011 # Using Test.pm version 1.25 Can't load 'blib/arch/auto/Conftest/Conftest.bundle' for module Confte +st: dlopen(blib/arch/auto/Conftest/Conftest.bundle, 2): no suitable i +mage found. Did find: blib/arch/auto/Conftest/Conftest.bundle: mach-o, but wrong archite +cture at /usr/local/ActivePerl-5.10/lib/DynaLoader.pm line 206. at test.pl line 2 Compilation failed in require at test.pl line 2. BEGIN failed--compilation aborted at test.pl line 2. not ok 1 # Failed test 1 in test.pl at line 1 # test.pl line 1 is: use Test; BEGIN { plan tests => 1; } END { ok($l +oaded) } make: *** [test_dynamic] Error 2 system call to 'make test 'OTHERLDFLAGS='' failed at Makefile.PL line +470. no libxml2 not found Try setting LIBS and INC values on the command line Or get libxml2 from http://xmlsoft.org/ If you install via RPMs, make sure you also install the -devel RPMs, as this is where the headers (.h files) are.
Any idea what I'm doing wrong?

Replies are listed 'Best First'.
Re: Installation problem - XML::LibXML on snow leopard with ActivePerl
by Sherm (Sexton) on Jan 27, 2011 at 05:21 UTC
    Try 'perl Makefile.PL XMLPREFIX=/usr/local'. With that, it should be able to run xml2-config to figure out the rest.
      Looks like this time around, it is actually finding & using xml-config but still no dice:
      perl Makefile.PL XMLPREFIX='/usr/local' Set up build environment without MacOSX10.4u SDK (will build native bi +naries) enable native perl UTF8 running xml2-config...untested Note: libxml2 2.7.8 was not tested with this XML::LibXML version. looking for -lxml2... no looking for -llibxml2... no libxml2 not found Try setting LIBS and INC values on the command line Or get libxml2 from http://xmlsoft.org/ If you install via RPMs, make sure you also install the -devel RPMs, as this is where the headers (.h files) are.
        The debug output above shows another problem: "ld: warning: in /usr/local/lib/libiconv.dylib, missing required architecture x86_64 in file" Looks like libiconv was built as 32-bit only - you'll need to fix that to use it from a 64-bit Perl.

      I am encountering this problem, albeit under slightly different conditions.   And this solution just feels cumbersome...   Is it indeed the case that, if you are encountering a lib-path problem in the installation of this package, that you must (I think...) look at the package in cpan and then type this command?   Instead of simply being able to install it?

      Is there (not?) a way to specify the library search path, by means of some cpan-configuration entry or another?   It’s all just so wonderfully automatic, so much of the time ... isn’t there a cleaner and therefore better way to do this?

      (See also: http://www.perlmonks.org/?node_id=847888.   I am by no means the first person across many years to have encountered or discussed this; this I know.   I’m not saying that anything about it is per se “wrong,” only that it feels like driving around on a square wheel.)   Note that on the target system a compatible version of the underlying library is installed, just not in a place where the CPAN installer script can find it.   Is there a “really good” way to specify this kind of environment-related info?