Static compile for OS X .app distribution

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
heisters

Static compile for OS X .app distribution

Post by heisters »

I'm trying to compile the "convert" executable so that I can distribute as part of my .app. I've followed all the instructions for doing this that I can find, but my users report "dyld: Library not loaded: /opt/local/lib/libtiff.3.dylib" errors, and otool seems to indicate that the executable is linked against the libtiff provided by MacPorts. I'm building on OS X 10.5.8, and would like to support 10.4-6.

This is my build script:

Code: Select all

$ cat build_imagemagick.bash 
#!/bin/bash

target_dir=`pwd`
cd build

im_dir=`ls | grep ImageMagick- | tail -n1`

cd "$im_dir"
delegates=(jpeg png tiff)
for delegate in ${delegates[@]}
do
  cd $delegate
  make distclean
  ./configure --disable-shared
  make
  cd ..
done

make distclean
./configure --disable-shared --enable-delegate-build \
  --prefix="$target_dir/ImageMagick.framework" --without-magick-plus-plus \
  --without-perl --without-x --without-freetype
make
make install
... and here is the output of otool after running this build:

Code: Select all

$ otool -L ImageMagick.framework/bin/convert 
ImageMagick.framework/bin/convert:
	/opt/local/lib/libtiff.3.dylib (compatibility version 12.0.0, current version 12.2.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)
	/opt/local/lib/libjasper.1.dylib (compatibility version 2.0.0, current version 2.0.0)
	/opt/local/lib/libjpeg.62.dylib (compatibility version 63.0.0, current version 63.0.0)
	/opt/local/lib/libpng12.0.dylib (compatibility version 36.0.0, current version 36.0.0)
	/opt/local/lib/libbz2.1.0.dylib (compatibility version 1.0.0, current version 1.0.5)
	/opt/local/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
I'll admit I'm not very expert with C compilation, and less so on non-Linux platforms. Any help will be greatly appreciated.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Static compile for OS X .app distribution

Post by fmw42 »

not sure if this will help but see viewtopic.php?f=1&t=14568
heisters

Re: Static compile for OS X .app distribution

Post by heisters »

fmw42 wrote:not sure if this will help but see viewtopic.php?f=1&t=14568
Thanks, but I don't see a link to the XCode project mentioned, so it's not of much help.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Static compile for OS X .app distribution

Post by fmw42 »

heisters wrote:
fmw42 wrote:not sure if this will help but see viewtopic.php?f=1&t=14568
Thanks, but I don't see a link to the XCode project mentioned, so it's not of much help.

Send a private message to User vishvesh using the User Control Panel link in the upper right corner of Discourse server window.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Static compile for OS X .app distribution

Post by magick »

The ImageMagick configure script looks in /opt/local for certain delegate libraries such as JPEG, PNG, or TIFF. This is quite convenient for building ImageMagick for your local host but not so much for redistribution. The solution is to remove the reference to /opt/local in your configure script or to rename /opt/local to /opt/local~, build ImageMagick, and then name it back. Another solution would be to replace the dynamic TIFF library with a static version.
heisters

Re: Static compile for OS X .app distribution

Post by heisters »

magick wrote:The ImageMagick configure script looks in /opt/local for certain delegate libraries such as JPEG, PNG, or TIFF. This is quite convenient for building ImageMagick for your local host but not so much for redistribution. The solution is to remove the reference to /opt/local in your configure script or to rename /opt/local to /opt/local~, build ImageMagick, and then name it back. Another solution would be to replace the dynamic TIFF library with a static version.
Hm, interesting. I thought "--enable-delegate-build" would make configure prefer the local libraries? Uninstalling the libraries from /opt/local causes the delegates to not be built at all, so it seems to be missing the library subdirectories either way.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Static compile for OS X .app distribution

Post by magick »

For the delegate build, unpack the delegate library in the top level ImageMagick folder as the format name. For example, PNG needs to be in this folder: ImageMagck-6.5.6-10/png. Now build the delegate library statically, for example:
  • cd png
    ./configure --disable-shared --disable-dependency-tracking
Now move to the top level and build ImageMagick:
  • ./configure --disable-shared --disable-dependency-tracking --enable-delegate-build --disable-installed --without-frozenpaths --prefix=/ImageMagick-6.5.5
    make
    make install
The ImageMagick distribution should now have support for PNG.
Post Reply