Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ImageMagic installed via Homebrew doesn't work #39

Open
jkamenik opened this issue Dec 1, 2011 · 10 comments
Open

ImageMagic installed via Homebrew doesn't work #39

jkamenik opened this issue Dec 1, 2011 · 10 comments

Comments

@jkamenik
Copy link

jkamenik commented Dec 1, 2011

I use a Mac, and homebrew for many packages including ImageMagick. I noticed a very annoying issue that I had to work around. Homebrew symlinks to /usr/local/bin and /usr/local/include. For example: /usr/local/include/ImageMagick -> /usr/local/homebrew/.../ImageMagick. This works fine with most libraries that need imagemagick since Magick-config produces the correct paths to the symlinks and the compilers just follow the sym links.

The rmagic gem compile does not seem capible of following symlinks and therefore cannot find /usr/local/include/wand/MagickWand.h which is there.

$ gem install rmagick
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

        /Users/jkamenik/.rvm/rubies/ruby-1.8.7-p352/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for /usr/bin/gcc-4.2... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no

Can't install RMagick 2.13.1. Can't find MagickWand.h.
*** 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/jkamenik/.rvm/rubies/ruby-1.8.7-p352/bin/ruby

My solution was to install ImageMagick via https://github.com/maddox/magick-installer/blob/master/magick-installer.sh, which doesn't use symlinks. Without symlinks things work fine.

@ged
Copy link

ged commented May 9, 2012

Works for me:

$ brew info imagemagick
imagemagick 6.7.1-1
http://www.imagemagick.org
Depends on: jpeg, libtiff, little-cms, jasper
/usr/local/Cellar/imagemagick/6.7.1-1 (1390 files, 32M)
  Installed with: --use-lqr

Some tools will complain unless the ghostscript fonts are installed to:
  /usr/local/share/ghostscript/fonts

http://github.com/mxcl/homebrew/commits/master/Library/Formula/imagemagick.rb

$ gem install rmagick
Fetching: rmagick-2.13.1.gem (100%)
Building native extensions.  This could take a while...
Successfully installed rmagick-2.13.1
1 gem installed
Installing RDoc documentation for rmagick-2.13.1...

$ ruby -v -rrmagick -e 'puts Magick::Version, Magick::Magick_version'
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]
RMagick 2.13.1
ImageMagick 6.7.1-1 2012-02-08 Q16 http://www.imagemagick.org

@arthurnn
Copy link

probably u will find the solution in here: rmagick/rmagick#60

@linduxed
Copy link

linduxed commented Nov 2, 2013

Looks like a candidate for closing, @mmaiza.

@rayning0
Copy link

Despite trying everything and following all StackOverflow recommendations, I can't install rmagick. Ugh. Help!

>> brew install imagemagick
==> Downloading https://homebrew.bintray.com/bottles/imagemagick-6.9.1-1.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/imagemagick-6.9.1-1.yosemite.bottle.tar.gz
==> Pouring imagemagick-6.9.1-1.yosemite.bottle.tar.gz
🍺  /usr/local/Cellar/imagemagick/6.9.1-1: 1442 files, 22M

>> gem install rmagick -v '2.14.0'
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

    /Users/user/.rvm/rubies/ruby-2.0.0-p576/bin/ruby -r ./siteconf20150523-64299-wdehb3.rb extconf.rb
checking for /usr/bin/clang... yes
checking for Magick-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
/usr/local/bin/Magick-config: line 41: pkg-config: command not found
/usr/local/bin/Magick-config: line 47: pkg-config: command not found
/usr/local/bin/Magick-config: line 50: pkg-config: command not found
/usr/local/bin/Magick-config: line 53: pkg-config: command not found
checking for Ruby version >= 1.8.5... yes
/usr/local/bin/Magick-config: line 53: pkg-config: command not found
Can't install RMagick 2.14.0. Can't find the ImageMagick library or one of the dependent libraries. Check the mkmf.log file for more detailed information.

*** 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/user/.rvm/rubies/ruby-2.0.0-p576/bin/ruby

extconf failed, exit code 1

@rayning0
Copy link

Aha! Reinstalling pkg-config FINALLY fixed my problem!!! http://stackoverflow.com/a/23957018/2175188

@RomanKapitonov
Copy link

Reinstalling pkg-config didn't help.

Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
  ERROR: Failed to build gem native extension.

    /Users/user/.rvm/rubies/ruby-1.9.3-p550/bin/ruby -r ./siteconf20160211-3780-jyhc8n.rb extconf.rb
checking for /usr/local/opt/gcc48/bin/gcc-4.8... yes
checking for Magick-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... *** 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
  --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/user/.rvm/rubies/ruby-1.9.3-p550/bin/ruby
/Users/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
  from /Users/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
  from /Users/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/mkmf.rb:931:in `block in have_header'
  from /Users/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
  from /Users/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
  from /Users/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/mkmf.rb:254:in `open'
  from /Users/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
  from /Users/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/mkmf.rb:254:in `open'
  from /Users/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
  from /Users/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
  from /Users/user/.rvm/rubies/ruby-1.9.3-p550/lib/ruby/1.9.1/mkmf.rb:930:in `have_header'
  from extconf.rb:38:in `configure_headers'
  from extconf.rb:18:in `initialize'
  from extconf.rb:517:in `new'
  from extconf.rb:517:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/user/.rvm/gems/ruby-1.9.3-p550/gems/rmagick-2.15.4 for inspection.
Results logged to /Users/user/.rvm/gems/ruby-1.9.3-p550/extensions/x86_64-darwin-14/1.9.1/rmagick-2.15.4/gem_make.out

I've already spent several hours on this. Please help.

mkmf.log file contains the following:

find_executable: checking for /usr/local/opt/gcc48/bin/gcc-4.8... -------------------- yes

--------------------

find_executable: checking for Magick-config... -------------------- yes

--------------------

configure_compile_options: checking for outdated ImageMagick version (<= 6.4.9)... -------------------- no

Detected ImageMagick version: 6.9.3
--------------------

assert_minimum_ruby_version!: checking for Ruby version >= 1.8.5... -------------------- yes

--------------------

"/usr/local/opt/gcc48/bin/gcc-4.8 -o conftest -I/Users/user/.rvm/rubies/ruby-1.9.3-p550/include/ruby-1.9.1/x86_64-darwin14.0.0 -I/Users/user/.rvm/rubies/ruby-1.9.3-p550/include/ruby-1.9.1/ruby/backward -I/Users/user/.rvm/rubies/ruby-1.9.3-p550/include/ruby-1.9.1 -I.  -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/local/Cellar/imagemagick/6.9.3-0_2/include/ImageMagick-6  -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/local/Cellar/imagemagick/6.9.3-0_2/include/ImageMagick-6 conftest.c  -L. -L/Users/user/.rvm/rubies/ruby-1.9.3-p550/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib  -L/usr/local/Cellar/imagemagick/6.9.3-0_2/lib -lMagickCore-6.Q16    -L/usr/local/Cellar/imagemagick/6.9.3-0_2/lib -lMagickCore-6.Q16  -lruby.1.9.1  -lpthread -ldl -lobjc "
In file included from /Users/user/.rvm/rubies/ruby-1.9.3-p550/include/ruby-1.9.1/ruby/defines.h:29:0,
                 from /Users/user/.rvm/rubies/ruby-1.9.3-p550/include/ruby-1.9.1/ruby/ruby.h:67,
                 from /Users/user/.rvm/rubies/ruby-1.9.3-p550/include/ruby-1.9.1/ruby.h:32,
                 from conftest.c:1:
/usr/include/stdlib.h:177:167: error: expected ',' or ';' before '__WATCHOS_PROHIBITED'
 int  system(const char *) __DARWIN_ALIAS_C(system) __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_0,__MAC_NA,__IPHONE_2_0,__IPHONE_8_0, "Use posix_spawn APIs instead.") __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
                                                                                                                                                                       ^
In file included from /Users/user/.rvm/rubies/ruby-1.9.3-p550/include/ruby-1.9.1/ruby/defines.h:29:0,
                 from /Users/user/.rvm/rubies/ruby-1.9.3-p550/include/ruby-1.9.1/ruby/ruby.h:67,
                 from /Users/user/.rvm/rubies/ruby-1.9.3-p550/include/ruby-1.9.1/ruby.h:32,
                 from conftest.c:1:
/usr/include/stdlib.h:267:165: error: expected ',' or ';' before '__WATCHOS_PROHIBITED'
 int  daemon(int, int) __DARWIN_1050(daemon) __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_0, __MAC_10_5, __IPHONE_2_0, __IPHONE_2_0, "Use posix_spawn APIs instead.") __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
                                                                                                                                                                     ^
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

Why would it even check for old version of imagemagick?

@RomanKapitonov
Copy link

Nevermind, I had ruby installed under previous version of Mac OS X. Reinstalling ruby fixed the issue. just run rvm reinstall [you-version-of-ruby] and you are done.

@Shekharrajak
Copy link

May be you are installing ImageMagick version 7.x.x which will generate different folder names in your usr/lib/local/include/ImageMagick7.x.x folder.

In ImageMagick6.x.x version we have magick, wand named folders, where in ImageMagick7.x.x version have named this MagickCore , MagickWand . So this updation is causing the problem in some gem installation like here. Which is using
magick/some_header.h or wand/some_header.h (Means they are not updated with the new 7.x.x ImageMagick version).

That's why we are getting this error :


    checking for outdated ImageMagick version (<= 6.4.9)... no
    checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
     .... 
    checking for wand/MagickWand.h... no

and in log file something like this :

error: 'MagickCore/method-attribute.h' file not found
#include "MagickCore/method-attribute.h"
         ^

Solution

Install the ImageMagick6.x.x version in your system from the official site : https://www.imagemagick.org/download/ and install it using this commands(after extract zip/tar) :

./configure
make 
make install

Then do

gem install rmagick

It will work.

@sragu
Copy link

sragu commented Mar 10, 2017

You could also install imagemagick 6 with homebrew

brew install imagemagick@6
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opt/imagemagick@6/lib/pkgconfig

@tungvn
Copy link

tungvn commented May 16, 2018

Confirm solution of @sragu is worked. But I lost this env variable each time I log out/restart or sthg like that.
Solution is add the above line into ./bash_profile:

echo "export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opt/imagemagick@6/lib/pkgconfig" >> ~/.bash_profile

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants