14

I understand that this question has been asked a lot earlier, but none of the solutions worked for me and I'm really desperate right now.

I'm trying to get rMagick to install using gem for an installation of diaspora. I already installed imagick via homebrew and when trying to run gem install rmagick I receive this error:

ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

        /Users/tobischweiger/.rvm/rubies/ruby-1.9.3-p385/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc-4.2... yes
checking for Magick-config... no
Can't install RMagick 2.13.2. Can't find Magick-config in /Users/tobischweiger/.rvm/gems/ruby-1.9.3-p385@diaspora/bin:/Users/tobischweiger/.rvm/gems/ruby-1.9.3-p385@global/bin:/Users/tobischweiger/.rvm/rubies/ruby-1.9.3-p385/bin:/Users/tobischweiger/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/tobischweiger/.rvm/rubies/ruby-1.9.3-p385/bin/ruby


Gem files will remain installed in /Users/tobischweiger/.rvm/gems/ruby-1.9.3-p385@diaspora/gems/rmagick-2.13.2 for inspection.
Results logged to /Users/tobischweiger/.rvm/gems/ruby-1.9.3-p385@diaspora/gems/rmagick-2.13.2/ext/RMagick/gem_make.out

I'm not very experienced with gem and homebrew and I'm wondering if somebody could help me out.

Marcelo De Polli
  • 28,123
  • 4
  • 37
  • 47
knurb
  • 475
  • 1
  • 4
  • 14

10 Answers10

23

Run this (using homebrew) before attempting to install the gem.

brew install imagemagick
Marcelo De Polli
  • 28,123
  • 4
  • 37
  • 47
  • Thank you for that answer. Like I stated in my original post, I already tried doing that. The results were the same. If it helps, I tried it again and this is the message from the brew install: ==> Downloading http://downloads.sf.net/project/machomebrew/mirror/ImageMagick-6 Already downloaded: /Library/Caches/Homebrew/imagemagick-6.7.7-6.tar.bz2 ==> Patching patching file configure Hunk #1 succeeded at 32371 (offset 447 lines). ==> ./configure --disable-osx-universal-binary --without-perl --prefix=/usr/loca ==> make install Error: Empty installation – knurb Mar 25 '13 at 05:03
  • I can run those commands with any problems, tried running gem insatll rmagick and it's still giving me the same error. – knurb Mar 26 '13 at 02:05
  • The thing is, you really need to install imagemagick as a dependency, there's no way around it. And homebrew is the easiest way to do it. Have you tried installing it *after* running `brew update`? If you run `brew list`, do you see imagemagick listed? – Marcelo De Polli Mar 26 '13 at 02:13
16

This is the less destructive version using homebrew, rmagic also doesn't work with imagemacigk version 7

ImageMagick Version 6.4.9 or later (6.×.x). Version 7 is NOT yet supported; ETA April 2019 (https://github.com/rmagick/rmagick/pull/299 )

(from Readme)

. You can get ImageMagick from www.imagemagick.org., so with brew try this

brew install imagemagick@6
PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig gem install rmagick
anquegi
  • 11,125
  • 4
  • 51
  • 67
4

I'm using OS X Lion.

I ran brew doctor and saw that imagemagick was unlinked so it told me to run brew link imagemagick.

Then I closed and re-opened my terminal and everything worked thankfully.

Dex
  • 12,527
  • 15
  • 69
  • 90
  • Awesome! Solve my problem! I have a love-hate relationship with rmagick/imagemagick. It's such a pain to install, but so nice to use. – Automatico Jul 02 '14 at 12:00
4

On Mavericks, you can do it:

brew install pkgconfig
brew uninstall imagemagick
brew install imagemagick
brew link imagemagick
bundle install

It's enough. I think.

Franzé Jr.
  • 1,194
  • 13
  • 20
3

I had a similar issue and this worked for me:

$ 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

Hope this helps.

Credit: https://coderwall.com/p/wnomjg

Eric M.
  • 5,399
  • 6
  • 41
  • 67
  • This works for me because I got different error stacks from this post, only checking for InitializeMagick() are failed. – Xiaohui Zhang Jul 22 '14 at 08:39
3

Make sure when you do these:

$ 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

that you change the file names to reflect your version: you can see the filenames by looking in the lib folder here: cd /usr/local/Cellar/imagemagick/VERSION/lib

ex:

ln -s libMagickWand-6.Q16.1.dylib libMagickWand.dylib

and so on

Aslan Varoqua
  • 191
  • 1
  • 6
2

There are different scenarios we need to check while installing RMagick. Please check following and confirm:

  1. Check if you are not installing latest version of RMagick with older version of ruby. i.e. ruby 1.8.7 or so. You can not install latest version of RMagick with older version of Ruby. If so, you will probably get this error message.

    Building native extensions.  This could take a while...
    ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.
    
      /Users/user/.rbenv/versions/1.8.7-p375/bin/ruby extconf.rb
    
  2. Make sure you have installed imagemagick before you install RMagick.

    brew install imagemagick
    
  3. Also make sure you are installing RMagick with compatible version of imagemagick. RMagick is not compatible with latest version of imagemagick.

More to this: instead of using RMagick you can use MiniMagick if you just need to resize, sharpen, transform existing images. RMagick is required when we need to create image, graphs, drawings and typography. It’s easier to work with and much lighter on system resources than RMagick. RMagick consumes huge amount of memory.

Naresh Thakur
  • 335
  • 2
  • 11
1

The main issue seems to be getting imagemagick properly installed and linked.

This page was very helpful for me:

http://sethvargo.com/20110726/install-imagemagick-on-mountain-lion/

I'm running homebrew, and getting the brew doctor command to run clean was the key to getting this to install.

mpelzsherman
  • 707
  • 9
  • 9
0

I found that updating my Xcode to the latest version (4.6.1) on OSX 1.8.2 fixed this problem and I Successfully installed rmagick-2.13.2

muce
  • 1
  • 1
0

For me, I had to look at the output which in your case is

/Users/tobischweiger/.rvm/gems/ruby-1.9.3-p385@diaspora/gems/rmagick-2.13.2/ext/RMagick

In there is a file called mkmf.log that lists exactly what it is trying to compile and the error. For me, the linker was failing with this command:

ld: library not found for -lMagickCore

Reviewing the command it was running it looked good except for the very end, see this snippet:

-lMagickCore-6.Q16 -lMagickCore-6.Q16 -lruby-static -framework CoreFoundation -lMagickCore -lpthread -ldl -lobjc -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/lib/darwin/libclang_rt.osx.a

Note that it got the output from Magick-config and used those by adding -lMagickCore-6.Q16 but it was still trying to link -lMagickCore. I think this is a byproduct of the have_library extconf is using. Important for me, was that there was no libMagickCore.dylib library provided by Homebrew. It could be an old version of rubygems and I think the correct fix would be to update the have_library function but I fixed it by making a symlink called libMagickCore.dylib that pointed to libMagickCore-6.Q16.dylib.

James
  • 1,118
  • 7
  • 13