Page 1 of 1

Static compile for OS X .app distribution

Posted: 2009-10-09T17:19:32-07:00
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.

Re: Static compile for OS X .app distribution

Posted: 2009-10-09T17:25:08-07:00
by fmw42
not sure if this will help but see viewtopic.php?f=1&t=14568

Re: Static compile for OS X .app distribution

Posted: 2009-10-09T17:48:29-07:00
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.

Re: Static compile for OS X .app distribution

Posted: 2009-10-09T18:17:31-07:00
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.

Re: Static compile for OS X .app distribution

Posted: 2009-10-09T18:21:14-07:00
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.

Re: Static compile for OS X .app distribution

Posted: 2009-10-10T18:44:20-07:00
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.

Re: Static compile for OS X .app distribution

Posted: 2009-10-10T19:20:54-07:00
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.