cpanm use custom libs and cflags
Asked Answered
W

2

6

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?

Wiskind answered 27/2, 2017 at 11:30 Comment(0)
M
6

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
Montherlant answered 30/3, 2017 at 13:13 Comment(0)
R
8

I think you were missing quotes around the --cflags argument (needed in order to group multiple space-separated arguments together):

--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'"

However --cflags and --libs are just examples from the cpanm documentation, and might not even be recognized by a distribution's Makefile.PL. As the other answer points out, the arguments to use for XML::LibXSLT are INC="…" and LIBS="…"; I think providing those to cpanm's --configure-args should work:

cpanm --configure-args="INC='…' LIBS='…'"
Rhaetic answered 12/6, 2019 at 17:39 Comment(0)
M
6

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
Montherlant answered 30/3, 2017 at 13:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.