Building imagemagick with a custom libxml2

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
tfoertsch
Posts: 6
Joined: 2010-06-10T11:40:44-07:00
Authentication code: 8675308

Building imagemagick with a custom libxml2

Post by tfoertsch »

Hi,

I have a libxml2 installed in /opt/libxml2 that I want to link imagemagick to. The system itself has another libxml2 installed in /usr/lib64. But the development files for this version are not installed.

To make sure it takes the right libxml2 I already set a bunch of environment variables:

export PATH=/opt/libxml2/bin:/opt/perl/bin:/opt/openssl/bin:/usr/bin:/bin
export LD_RUN_PATH=/opt/openssl/lib64:/opt/libxml2/lib64
export CPATH=/opt/openssl/include:/opt/libxml2/include/libxml2
export LIBRARY_PATH=/opt/openssl/lib64:/opt/libxml2/lib64
export CFLAGS='-I/opt/openssl/include -I/opt/libxml2/include/libxml2'
export CPPFLAGS='-I/opt/openssl/include -I/opt/libxml2/include/libxml2'
export LDFLAGS='-L/opt/openssl/lib64 -L/opt/libxml2/lib64'
export XML2_CONFIG=/opt/libxml2/bin/xml2-config

But they are of no help. I still get this error during "make":

...
CC coders/coders_tiff_la-tiff.lo
CCLD coders/tiff.la
CC coders/coders_wmf_la-wmf.lo
CCLD coders/wmf.la
/usr/bin/grep: /usr/lib64/libxml2.la: No such file or directory
/usr/bin/sed: can't read /usr/lib64/libxml2.la: No such file or directory
libtool: link: `/usr/lib64/libxml2.la' is not a valid libtool archive

Why the hell does it look for /usr/lib64/libxml2.la instead of /opt/libxml2/lib64/libxml2.la?

In the configure stage it looks good:
...
checking for XML...
checking for xml2-config... xml2-config
checking libxml/parser.h usability... yes
checking libxml/parser.h presence... yes
checking for libxml/parser.h... yes
checking for xmlParseExternalEntity in -lxml2... yes
checking if XML package is complete... yes
...
Last edited by tfoertsch on 2011-07-17T10:45:09-07:00, edited 1 time in total.
tfoertsch
Posts: 6
Joined: 2010-06-10T11:40:44-07:00
Authentication code: 8675308

Re: Building imagemagick with a custom libxml2

Post by tfoertsch »

As a followup, I still get the error if imagemagick is configured without xml:

Delegate Configuration:
...
XML --with-xml=no no
ZLIB --with-zlib=yes yes
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Building imagemagick with a custom libxml2

Post by fmw42 »

I don't believe that is an error message.

To see what delegates IM knows about type

convert -list configure

look at the line starting with DELEGATES. For example here is mine:

DELEGATES bzlib fftw fontconfig freetype gs jpeg jng jp2 lcms2 lqr lzma mpeg openexr png rsvg tiff x11 xml zlib


I assume you are on a Mac. I have installed all my delegates from MacPorts, but install IM manually so I can keep up with the latest IM. Here is my config file:


./configure CPPFLAGS='-I/opt/local/include' LDFLAGS='-L/opt/local/lib' \
--enable-delegate-build --enable-shared --disable-static \
--with-modules --with-quantum-depth=16 --with-gslib --without-wmf \
--disable-silent-rules --disable-dependency-tracking --disable-openmp \
--with-gs-font-dir=/opt/local/share/ghostscript/fonts/ --with-lqr


I am on a mac Mini G4 PowerPC running OSX Tiger.

I am no expert on this, but the first two fields CPPFLAGS and LDFLAGS are the important ones to point to where MacPorts installs things.

If every thing including IM is installed with MacPorts, then you may not need these items, but again I am not an expert and have not done it that way. I had to get help with doing the above myself as I am not unix expert.

see
http://www.imagemagick.org/script/advan ... lation.php
tfoertsch
Posts: 6
Joined: 2010-06-10T11:40:44-07:00
Authentication code: 8675308

Re: Building imagemagick with a custom libxml2

Post by tfoertsch »

No, it's Linux not a Mac.

The problem is I have a libxml2 in /opt/libxml2/lib64. There is also a libxml2.la in that directory. However, in /usr/lib64 where it looks for libxml2.la is only a libxml2.so.2.7.8.

I want imagemagick to use the library in /opt/libxml2 no matter if there is another libxml2 elsewhere.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Building imagemagick with a custom libxml2

Post by fmw42 »

I never figured out how to do that with only one delegate coming from /opt and all the rest coming from /usr. If you find out how to do that, I would appreciate your feedback on the forum in this topic.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Building imagemagick with a custom libxml2

Post by anthony »

More than likely IM is just doing a standard library search using the current LD_LIBRARY_PATH
if you what it to find your libxml2 before the system version, make sure you list your library before the system library in that environment variable.

The only other solution would be to somehow modify the build process to code the path into the executable, but the IM makefile is very complex and difficult to modify, and I am not certain on exactly what you need to do to set it. I think the linking line needs a -R path rather than a -L path. The security HowTos (general not IM) should help as restricting what libraries are used is also a major security concern for SUID programs.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
tfoertsch
Posts: 6
Joined: 2010-06-10T11:40:44-07:00
Authentication code: 8675308

Re: Building imagemagick with a custom libxml2

Post by tfoertsch »

Turns out that libwmf also requires libxml2. Now, I have 2 options. First, rebuild libwmf with my libxml2 or, second, turn off libwmf. Since I don't need windows metafile images I went for 2. Now it compiles and passes all tests. I also added -rpath options to make sure the correct lib is loaded at runtime.
Post Reply