perlcpanxml-libxmlcpanm

cpanm use custom libs and cflags


On my mac OS X machine Darwin maci 15.6.0 Darwin Kernel Version 15.6.0

I have installed libxml2 and libxslt in following custom directory

/usr/local/MyLibs/libxml2-2.9.2

and libxslt

/usr/local/MyLibs/libxslt-1.1.29

Now I want to use these libs to build my CPANM module XML::LibXSLT.

This tells me that I can do so using --configure-args (its still experimental). So I do something like,

cpanm http://search.cpan.org/CPAN/authors/id/S/SH/SHLOMIF/XML-LibXSLT-1.94.tar.gz --configure-args="--cflags=-I/usr/local/libxslt-1.1.29/include -I/usr/include/libxml2 -I/usr/local/MyLibs/libxml2-2.9.2/include/libxml2 --libs=-L/usr/local/libxslt-1.1.29/lib -lxslt -lxml2 -lz -lpthread -licucore -lm -L/usr/local/MyLibs/libxml2-2.9.2/lib -lxml2 -lz -lpthread -liconv -lm" --force

However, the build log says that it did not use the libraries installed in my custom location.

Is there something that I am not doing correctly?


Solution

  • From the distro's README,

    The Makefile.PL tries to determine the correct compiler and linker flags for its library dependencies using pkg-config and xslt-config. If this fails, you may override the values like this

    perl Makefile.PL INC="..." LIBS="..."
    

    where INC contains flags for the compiler (such as -I/some_path/include etc.) and LIBS contains linker flags (such as -L/some_path/lib -llibsomething ...).

    It might be simpler to forgo cpanm and install the module yourself.

    curl -L -o - http://search.cpan.org/CPAN/authors/id/S/SH/SHLOMIF/XML-LibXSLT-1.95.tar.gz | tar xz
    cd XML-LibXSLT-1.95
    perl Makefile.PL INC="..." LIBS="..."
    make test
    make install