Skip to content

Instantly share code, notes, and snippets.

@zjfroot
Last active December 19, 2015 10:59
Show Gist options
  • Save zjfroot/5944810 to your computer and use it in GitHub Desktop.
Save zjfroot/5944810 to your computer and use it in GitHub Desktop.
Compile a graphicsmagick executable that can be distributed to Mac OS 10.7 and 10.8
#Wrote by Jifeng Zhang Sun Jul 7 22:18:48 CEST 2013
cd ~/tmp
mkdir graphicsmagic
cd graphicsmagic
mkdir work
mkdir work/deps
#or mkdir -p work/deps
wget http://downloads.sf.net/project/libpng/libpng15/older-releases/1.5.14/libpng-1.5.14.tar.gz
wget http://www.ijg.org/files/jpegsrc.v8d.tar.gz
wget http://garr.dl.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.18/GraphicsMagick-1.3.18.tar.bz2
tar zxvf libpng-1.5.14.tar.gz
tar zxvf jpegsrc.v8d.tar.gz
tar zxvf GraphicsMagick-1.3.18.tar.bz2
cd jpeg-8d
./configure --prefix=$HOME/tmp/graphicsmagic/work/deps CC=clang CFLAGS=-mmacosx-version-min=10.7
make
make install
cd ..
cd libpng-1.5.14
./configure --prefix=$HOME/tmp/graphicsmagic/work/deps CC=clang CFLAGS=-mmacosx-version-min=10.7
make
make install
cd ..
cd GraphicsMagick-1.3.18
./configure CC=clang CFLAGS="-I$HOME/tmp/graphicsmagic/work/deps/include/ -mmacosx-version-min=10.7" LDFLAGS=-L$HOME/tmp/graphicsmagic/work/deps/lib --prefix=/Volumes/Data/pj/graphicsmagic/work
make
make install
cd ..
cd work/bin
#check linked libs
otool -L gm
#change the dylib location to the same folder of gm
install_name_tool -change $HOME/tmp/graphicsmagic/work/deps/lib/libpng15.15.dylib @executable_path/libpng15.15.dylib gm
install_name_tool -change $HOME/tmp/graphicsmagic/work/deps/lib/libjpeg.8.dylib @executable_path/libjpeg.8.dylib gm
cd ..
mkdir GraphicsMagick-1.3.18-macosx-bin
cd GraphicsMagick-1.3.18-macosx-bin
cp ../work/bin/gm .
cp ../work/deps/lib/libpng15.15.dylib .
cp ../work/deps/lib/libjpeg.8.dylib .
cd ..
tar cjvf GraphicsMagick-1.3.18-macosx-bin.tar.bz2 GraphicsMagick-1.3.18-macosx-bin
#clean up
cd jpeg-8d
make clean
cd ..
cd libpng-1.5.14
make clean
cd ..
cd GraphicsMagick-1.3.18
make clean
cd ..
rm -rf work
#Reference links
#http://stackoverflow.com/questions/14268887/what-is-the-illegal-instruction-4-error-and-why-does-mmacosx-version-min-10
#http://stackoverflow.com/questions/9098926/can-i-include-dylib-s-in-my-executable
#http://www.graphicsmagick.org/1.1/www/INSTALL-unix.html
#https://gist.github.com/ammmir/1210728
#http://ext.raneous.net/post/40106080462/building-graphicsmagick-on-osx
#https://github.com/mxcl/homebrew/blob/master/Library/Formula/libpng.rb
#https://github.com/mxcl/homebrew/blob/master/Library/Formula/graphicsmagick.rb
#https://github.com/mxcl/homebrew/blob/master/Library/Formula/jpeg.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment