Issue with installing ImageMagick and rmagick on Mountain Lion

社会主义新天地 提交于 2019-11-29 09:34:01

I just updated to Mountain Lion this morning and had rmagick troubles. I had installed ImageMagick through homebrew at some point in the past, so this worked for me after installing the new commandline tools through xcode's preferences window.

brew update
brew uninstall ImageMagick
brew install ImageMagick
gem uninstall rmagick
gem install rmagick

I didn't have to get funky with gcc like some above posts mentioned.

I finally solved this using:

$ 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

The solution comes from https://coderwall.com/p/wnomjg

I was getting the same

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

did it as it says in https://gist.github.com/1860511

So after updating my mac pro to Mountain Lion, my ruby environment started screaming with different errors one after another. After 1-2 hours of trial - error and googling, here is how I fixed my ruby on rails environment.

First I got ruby env errors.It was not detecting git commands and Bundler was screaming with errors when I ran foreman start

Step1 : Update XCode. Get the latest one Xcode 4.6 Mountain Lion does not come with ruby headers installed before hand, so you need to do this manually from XCode. Go to Xcode Preferences/Downloads.

Install Command Line Tools

Step2: Install XQuartz

Logout and Login again. (You might not need this as imagemagick formula has been updated

Step 3: Now your ruby env would start speaking about Imagemagick errors Do this:

brew update

brew uninstall imagemagick

brew install --fresh imagemagick

gem uninstall rmagick 2.13.2

gem install rmagick

After trying the last one, now it will give you native extension errors like this

Installing rmagick (2.13.1) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/priyanka/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb 
checking for Ruby version >= 1.8.5... yes
checking for /usr/bin/gcc-4.2... no
No C compiler found in ${ENV['PATH']}. See mkmf.log for details.
*** 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/priyanka/.rvm/rubies/ruby-1.9.2-p180/bin/ruby


Gem files will remain installed in /Users/priyanka/.rvm/gems/ruby-1.9.2-p180/gems/rmagick-      2.13.1 for inspection.
Results logged to /Users/priyanka/.rvm/gems/ruby-1.9.2-p180/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
An error occured while installing rmagick (2.13.1), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.1'` succeeds before bundling.

Step 4: sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

This should fix all issues that Mountain Lion gifted you after the upgrade.

Just run bundle.

Try changing your path such that /usr/local/bin is inserter before /usr/bin. I found this running brew doctor and it allowed me to finish compiling imagemagick.

Sanjay Kumar

Here is a quick summary of how I was able to get RMagick work, after several tries. I feel the following is the best way to get it without going to the pains of downloading source tarballs and compilation - leave that to experts

  • You need to have Xcode and Command Line Tools installed for gcc/g++ etc. Command line tools do not get installed automatically with Xcode, go Preferences and install it
  • Next install Macport
  • Install Homebrew as well
  • Make sure you have X11 server installed - if not install it - sudo port install -v xorg-server. I use -v option as it is a long install and you might wonder whether it is doing something or just hanging
  • Install pkgconfig - sudo brew install pkgconfig
  • now it is time to install ImageMacick - sudo port install -v ImageMagick
    do not use brew to install ImageMagick - it does not install all the dependencies and delegates properly.
  • once ImageMagick is installed - set DISPLAY env variable - export DISPLAY=:0.0 - better still put it in your .profile
  • Now test your ImageMagick installation
  • start X11 server (after X11 server installation it is will there in your App List)
  • from command line run - $convert logo: logo.gif; identify logo.gif; display logo.gif - it should pop up a window displaying logo.gif
  • also run a command from command line - $convert -list configure | grep -i delegates. It should output the following
    DELEGATES bzlib fftw fontconfig freetype gs jpeg jng lcms2 lzma png tiff x11 xml zlib

  • Now you should be set to run sudo gem install RMagick

After RMagick is installed successfully - check where it is installed, go to examples directory within and run some of the programs.

No solutions were working for me, eventually I ran brew doctor and discovered that I needed to link imagemagick with brew link --overwrite imagemagick

Lev Lukomsky

I had similar issue but on El Captain. Better explained here. Fixed after installing xcode command-line tools:

xcode-select --install

You need to install XCode 4.4, command line tools, etc. Check out the full listing here: http://tektastic.com/2012/07/getting-rmagic-and-friends-to-work-on.html

I found the solution for me was a combination of the steps listed above, at http://tektastic.com/2012/07/getting-rmagic-and-friends-to-work-on.html and here http://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion, although I didn't have to do all the steps listed in either post. But I did need to install the command line tools from XCode, I missed that detail the first few times. I also had to install gcc-4.2 using homebrew, and make a sym link to that installation in my bin directory.

I could be confused about what's going on with the different compilers, but I would be cautious about sym linking /usr/bin/gcc to /usr/bin/gcc-4.2 (which may in turn be a link to gcc-4.2 installed by homebrew). Before I realized I needed to install the command line tools, I had tried making that sym link and then I started seeing other gem build failures. Installing the command line tools fixed those issues - I believe the xcode command line tools made it a sym link to llvm-gcc-4.2.

I just installed rmagick 2.13.2 and this issue is gone.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!