How to compile FULLY STATIC under LInux?

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Klaws

How to compile FULLY STATIC under LInux?

Post by Klaws »

Hi,

I need to deploy ImageMagick's "convert" utility on a a shared host, where I don't have access to /usr/lib, env or anything else except the webspace. I can however drop a binary into the webspace, chmod it to 755 and run it (from the Apache context).

So what I did was to install Debian at home (inclunding gcc, and libtiff*-dev, libpng*.dev, jasper*-dev, etc) and compile a static version of ImageMagick (V6.4.0). I used the follging vonfigure command:

Code: Select all

./configure --enable-shared
The result was (among others) a "convert" binary with (very roughly) 6.5MB size. However, after deployment on the shared host, "convert" complains about a missing "libtiff.so.4" library (I also had to deploy the *.xml files to the web root, of course). A quick check with "ldd" on the development machine revealed indeed that the "static compile" of "convert" still requires shared libraries - none of ImageMagick's shared libraries, just the "standard libraries" like libtiff and libpng.

Just to verify thing I then tries a configure/make/deploy/test cycle with

Code: Select all

./configure --enable-shared --without-tiff --without-freetype --without-jpeg --without-jp2 --without-png --without-tiff
and everything went fine on the shared host - except, of course, that "convert" was now limited to handle GIFs. Unfortunately, I need it to handle JPEGs and PNGs as well....

My idea is that a fully static compile (or at least a compile where libtiff and libpng and whatever image format handling library is required) might help. Unfortunately, I didn't manage to get this done. Has anyone an idea on how to enlighten the linker to do what I want? Or any other solution, other than switching hosts?

Thanks, and best regards, Klaus
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: How to compile FULLY STATIC under LInux?

Post by magick »

For static deployment we add each delegate library to the ImageMagick folder named by its format name (e.g. ImageMagick-6.4.0/tiff for the TIFF delegate). Next build each delegate library static (e.g. ./configure --disable-shared). Now build ImageMagick with these options:
  • cd ImageMagick-6.4.0
    ./configure --disable-shared --enable-delegate-build
    make
The --enable-delegate-build option tells ImageMagick to pick up the local static version of the delegate library rather than the system shared delegate library.
Klaws

Re: How to compile FULLY STATIC under LInux?

Post by Klaws »

Thank you very much, it works!

Well, actually it still insist on ignoring libjpeg.a, but that's of no concern for me. :-)

Best regards, Klaus
Post Reply