How can I tell Perl XML::LibXML to use newer libxml2 library during runtime?

1.3k views Asked by At

Our machines come with libxml2 2.7.6 pre-installed on them. However, someone needed a newer version of libxml2 and installed 2.7.8 on our networked file system. Likewise, they used this version of libxml2 to compile their version of the Perl module XML::LibXML, a Perl interface for libxml2. This was also placed on the network drive and is meant for developer use.

I am currently trying to use their compiled version of XML::LibXML. My script finds the module just fine, but when it goes to run it, it complains that it was compiled against a newer version of libxml2 than the one the script is looking at:

Warning: XML::LibXML compiled against libxml2 20708, but runtime libxml2 is older 20706

Obviously the Perl script is still looking at the system's libxml2, but I need it to use the newer version. Rather than recompiling the XML::LibXML module against the old libxml2 library again, is there any way I can tell Perl to simply use the newer libxml2 library?

1

There are 1 answers

1
Gilles Quénot On

One solution :

BEGIN{ @INC = ( "/SPECIAL/PERL/MODULES/DEV/PATH", @INC );

The string

/SPECIAL/PERL/MODULES/DEV/PATH

is the PATH before

/SPECIAL/PERL/COMPILED/MODULES/DEV/PATH/XML/LibXML.pm

If instead the problem is the library PATH (*.so), then you should modify LD_LIBRARY_PATH :

BEGIN{ $ENV{'LD_LIBRARY_PATH'} = "/SPECIAL/SYSTEM/MODULES/DEV/PATH"; }