installing rmagick on 10.8 with homebrew

Trying to get a rails project running, I run bundle but rmagick won't install.

tried to install rmagick by itself with gem install rmagick -v '2.13.1'

it errors out:

checking for InitializeMagick() in -lMagickCore... no
checking for InitializeMagick() in -lMagick... no
checking for InitializeMagick() in -lMagick++... no

google tells me the names of these libs have changed, so run:

cd /usr/local/Cellar/imagemagick/6.8.0-10/lib
ln -s libMagick++-Q16.7.dylib   libMagick++.dylib
ln -s libMagickCore-Q16.7.dylib libMagickCore.dylib
ln -s libMagickWand-Q16.7.dylib libMagickWand.dylib

getting closer, we have a new error now:

ld: file not found: /usr/local/lib/libltdl.7.dylib for architecture x86_64

tried installing xquartz to no avail, so I uninstalled it:

launchctl unload /Library/LaunchAgents/org.macosforge.xquartz.startx.plist
sudo launchctl unload /Library/LaunchDaemons/org.macosforge.xquartz.privileged_startx.plist
sudo rm -rf /opt/X11* /Library/Launch*/org.macosforge.xquartz.* /Applications/Utilities/XQuartz.app /etc/*paths.d/*XQuartz
sudo pkgutil --forget org.macosforge.xquartz.pkg

run the above code only if you installed xquartz

turns out I had libltdl.7.dylib lying around in my libtool cellar, so I linked it up:

ln -s /usr/local/Cellar/libtool/2.4.2/lib/libltdl.7.dylib /usr/local/lib/libltdl.7.dylib

if you dont have libtool installed, just brew it up:

brew install libtool

don't forget to link libltdl.7.dylib if you had to install libtool