New issue

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

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

Already on GitHub? Sign in to your account

Now RMagick 2.15.4 can't be built with ImageMagick 7.0.x #256

Open
kb10uy opened this Issue Aug 11, 2016 · 28 comments

Comments

Projects
None yet
@kb10uy

kb10uy commented Aug 11, 2016

As ImageMagick renewed the prefix of its header files at version 7, I can't build RMagick with ImageMagick-7.0.2.

Probably #254 is related with this problem.

ImageMagick: Porting to ImageMagick Version 7

Header Files

Prior versions of ImageMagick (4-6) reference the ImageMagick header files as magick/ and wand/. > ImageMagick 7 instead uses MagickCore/ and MagickWand/ respectively. For example,

#include <MagickCore/MagickCore.h>
#include <MagickWand/MagickWand.h>

This is my build log on Raspberry Pi.

current directory: /home/kb10uy/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/rmagick-42aa8ce34f61/ext/RMagick
/home/kb10uy/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20160812-28804-12a4s7p.rb extconf.rb
checking for gcc... yes
checking for Magick-config... no
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no

Can't install RMagick 2.15.4. 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=/home/kb10uy/.rbenv/versions/2.3.1/bin/$(RUBY_BASE_NAME)

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/kb10uy/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/extensions/armv6l-linux/2.3.0-static/rmagick-42aa8ce34f61/mkmf.log

extconf failed, exit code 1
@bf4

This comment has been minimized.

Show comment
Hide comment
@bf4

bf4 Aug 11, 2016

Member

@kb10uy Would you be interested in making a PR to fix this?

Member

bf4 commented Aug 11, 2016

@kb10uy Would you be interested in making a PR to fix this?

@kb10uy

This comment has been minimized.

Show comment
Hide comment
@kb10uy

kb10uy Aug 12, 2016

@bf4 I'm just making a patch to fix this, but ImageMagick 7 has changed more than I thought.

The biggest one is about Pixel Channels. To handle images with 6 or more channels, ImageMagick 7 implemented Quantum type instead of PixelPacket. So I have to refactor the whole source of native library, and it may be uncompatible with ImageMagick 6...

kb10uy commented Aug 12, 2016

@bf4 I'm just making a patch to fix this, but ImageMagick 7 has changed more than I thought.

The biggest one is about Pixel Channels. To handle images with 6 or more channels, ImageMagick 7 implemented Quantum type instead of PixelPacket. So I have to refactor the whole source of native library, and it may be uncompatible with ImageMagick 6...

@vassilevsky

This comment has been minimized.

Show comment
Hide comment
@vassilevsky

vassilevsky Aug 12, 2016

Member

You can still do it and send a PR to the develop branch. We will release it as 3.x and add a note to README that will tell users to use 2.x for ImageMagick 6.x.

Member

vassilevsky commented Aug 12, 2016

You can still do it and send a PR to the develop branch. We will release it as 3.x and add a note to README that will tell users to use 2.x for ImageMagick 6.x.

@kb10uy

This comment has been minimized.

Show comment
Hide comment
@kb10uy

kb10uy Aug 12, 2016

@vassilevsky Okay, thanks. I'll continue this.

kb10uy commented Aug 12, 2016

@vassilevsky Okay, thanks. I'll continue this.

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Jan 12, 2017

This is now a biggest problem because the default ImageMagick version in Homebrew is now 7.0.

rafaelfranca commented Jan 12, 2017

This is now a biggest problem because the default ImageMagick version in Homebrew is now 7.0.

@hristozov

This comment has been minimized.

Show comment
Hide comment
@hristozov

hristozov Jan 12, 2017

A temporary fix for the Homebrew users is something like this:

brew rm imagemagick
cd "$(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/"
git checkout 6f014f2b7f1f9e618fd5c0ae9c93befea671f8be imagemagick.rb
brew install imagemagick
brew pin imagemagick
git reset --hard

The install step may decide to update homebrew-core and stash your changes to imagemagick.rb. In that case, just repeat the procedure.

Sorry for spamming this issue, but I hope that fix can be useful for the OS X people who get here 😄

hristozov commented Jan 12, 2017

A temporary fix for the Homebrew users is something like this:

brew rm imagemagick
cd "$(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/"
git checkout 6f014f2b7f1f9e618fd5c0ae9c93befea671f8be imagemagick.rb
brew install imagemagick
brew pin imagemagick
git reset --hard

The install step may decide to update homebrew-core and stash your changes to imagemagick.rb. In that case, just repeat the procedure.

Sorry for spamming this issue, but I hope that fix can be useful for the OS X people who get here 😄

@demonmind

This comment has been minimized.

Show comment
Hide comment
@demonmind

demonmind Jan 12, 2017

git checkout 6f014f2b7f1f9e618fd5c0ae9c93befea671f8be imagemagick.rb game me an error.

I ended up updating imagemagick.rb to the previous version via vim and did the install and it started working.

demonmind commented Jan 12, 2017

git checkout 6f014f2b7f1f9e618fd5c0ae9c93befea671f8be imagemagick.rb game me an error.

I ended up updating imagemagick.rb to the previous version via vim and did the install and it started working.

@drampelt

This comment has been minimized.

Show comment
Hide comment
@drampelt

drampelt Jan 13, 2017

Alternatively you can run the following to install the latest 6 release:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/6f014f2b7f1f9e618fd5c0ae9c93befea671f8be/Formula/imagemagick.rb

drampelt commented Jan 13, 2017

Alternatively you can run the following to install the latest 6 release:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/6f014f2b7f1f9e618fd5c0ae9c93befea671f8be/Formula/imagemagick.rb
@ledermann

This comment has been minimized.

Show comment
Hide comment
@ledermann

ledermann Jan 17, 2017

Now there is an official Imagemagick@6 formula (see Homebrew/homebrew-core/pull/8756), so we can do:

brew update
brew rm imagemagick
brew install imagemagick@6

LDFLAGS=-L/usr/local/opt/imagemagick@6/lib \
CPPFLAGS=-I/usr/local/opt/imagemagick@6/include \
PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig \
gem install rmagick

ledermann commented Jan 17, 2017

Now there is an official Imagemagick@6 formula (see Homebrew/homebrew-core/pull/8756), so we can do:

brew update
brew rm imagemagick
brew install imagemagick@6

LDFLAGS=-L/usr/local/opt/imagemagick@6/lib \
CPPFLAGS=-I/usr/local/opt/imagemagick@6/include \
PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig \
gem install rmagick
@pablocrivella

This comment has been minimized.

Show comment
Hide comment
@pablocrivella

pablocrivella Jan 17, 2017

@ledermann i installed imagemagick using that formula and also rmagick worked, but after that my system can't find imagemagick binaries (convert, identify...)
Any idea?

pablocrivella commented Jan 17, 2017

@ledermann i installed imagemagick using that formula and also rmagick worked, but after that my system can't find imagemagick binaries (convert, identify...)
Any idea?

@ledermann

This comment has been minimized.

Show comment
Hide comment
@ledermann

ledermann Jan 17, 2017

@pablocrivella You are right, it seems this helps:

brew link imagemagick@6 --force

ledermann commented Jan 17, 2017

@pablocrivella You are right, it seems this helps:

brew link imagemagick@6 --force
@pablocrivella

This comment has been minimized.

Show comment
Hide comment
@pablocrivella

pablocrivella Jan 17, 2017

Thanks! @ledermann, i can confirm is working now.

This are the commands i ran, to make it work on a app using bundler (No need for the build flags after linking)

brew update
brew rm imagemagick
brew install imagemagick@6
brew link imagemagick@6 --force
bundle

pablocrivella commented Jan 17, 2017

Thanks! @ledermann, i can confirm is working now.

This are the commands i ran, to make it work on a app using bundler (No need for the build flags after linking)

brew update
brew rm imagemagick
brew install imagemagick@6
brew link imagemagick@6 --force
bundle
@airspeed

This comment has been minimized.

Show comment
Hide comment
@airspeed

airspeed Jan 17, 2017

If you need to keep both versions for any reason, I can confirm manually linking IM6 from IM7 allows to successfully bundle:

ln -s /usr/local/Cellar/imagemagick@6/6.9.7-4/include/ImageMagick-6/magick /usr/local/Cellar/imagemagick/7.0.4-4/include/ImageMagick-7/magick
ln -s /usr/local/Cellar/imagemagick@6/6.9.7-4/include/ImageMagick-6/wand /usr/local/Cellar/imagemagick/7.0.4-4/include/ImageMagick-7/wand
bundle install

airspeed commented Jan 17, 2017

If you need to keep both versions for any reason, I can confirm manually linking IM6 from IM7 allows to successfully bundle:

ln -s /usr/local/Cellar/imagemagick@6/6.9.7-4/include/ImageMagick-6/magick /usr/local/Cellar/imagemagick/7.0.4-4/include/ImageMagick-7/magick
ln -s /usr/local/Cellar/imagemagick@6/6.9.7-4/include/ImageMagick-6/wand /usr/local/Cellar/imagemagick/7.0.4-4/include/ImageMagick-7/wand
bundle install
@MikeMcQuaid

This comment has been minimized.

Show comment
Hide comment
@MikeMcQuaid

MikeMcQuaid Jan 18, 2017

@pablocrivella You are right, it seems this helps:

brew link imagemagick@6 --force

Don't do that, add /usr/local/opt/imagemagick@6/bin to your $PATH instead.

MikeMcQuaid commented Jan 18, 2017

@pablocrivella You are right, it seems this helps:

brew link imagemagick@6 --force

Don't do that, add /usr/local/opt/imagemagick@6/bin to your $PATH instead.

@monolar

This comment has been minimized.

Show comment
Hide comment
@monolar

monolar Jan 18, 2017

brew update
brew rm imagemagick
brew install imagemagick@6

LDFLAGS=-L/usr/local/opt/imagemagick@6/lib
CPPFLAGS=-I/usr/local/opt/imagemagick@6/include
PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig
gem install rmagick

We needed to prepend export to the PKG_CONFIG_PATH part at least to get it working. I guess there is some subshell spawning stuff going on with exec or something.

monolar commented Jan 18, 2017

brew update
brew rm imagemagick
brew install imagemagick@6

LDFLAGS=-L/usr/local/opt/imagemagick@6/lib
CPPFLAGS=-I/usr/local/opt/imagemagick@6/include
PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig
gem install rmagick

We needed to prepend export to the PKG_CONFIG_PATH part at least to get it working. I guess there is some subshell spawning stuff going on with exec or something.

@sfandrew

This comment has been minimized.

Show comment
Hide comment
@sfandrew

sfandrew Jan 25, 2017

Btw, also ran issues with ImageMagick 7 with Mac OS X(10.12) and had to install ImageMagick6 with the package config pointing to it.
brew install imagemagick@6
PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig gem install rmagick

sfandrew commented Jan 25, 2017

Btw, also ran issues with ImageMagick 7 with Mac OS X(10.12) and had to install ImageMagick6 with the package config pointing to it.
brew install imagemagick@6
PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig gem install rmagick

@epetre

This comment has been minimized.

Show comment
Hide comment
@epetre

epetre Jan 27, 2017

Is there any way to get this to work with bundler?

epetre commented Jan 27, 2017

Is there any way to get this to work with bundler?

@DriftwoodJP

This comment has been minimized.

Show comment
Hide comment
@DriftwoodJP

DriftwoodJP Jan 31, 2017

My temporary solution for bundle rmagick & other brew package.

brew install imagemagick  <- for other dependencies package
brew install imagemagick@6  <- for rmagick
brew unlink imagemagick
brew link imagemagick@6 --force
bundle install

DriftwoodJP commented Jan 31, 2017

My temporary solution for bundle rmagick & other brew package.

brew install imagemagick  <- for other dependencies package
brew install imagemagick@6  <- for rmagick
brew unlink imagemagick
brew link imagemagick@6 --force
bundle install
@pablocrivella

This comment has been minimized.

Show comment
Hide comment
@pablocrivella

pablocrivella Jan 31, 2017

After updating to 6.9.7-6 i'm getting this error when trying to run my app 😓

/Users/pablocrivella/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `require': dlopen(/Users/pablocrivella/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rmagick-2.15.4/lib/RMagick2.bundle, 9): Library not loaded: /usr/local/opt/imagemagick@6/lib/libMagickCore-6.Q16.3.dylib (LoadError)
  Referenced from: /Users/pablocrivella/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rmagick-2.15.4/lib/RMagick2.bundle
  Reason: image not found - /Users/pablocrivella/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rmagick-2.15.4/lib/RMagick2.bundle

EDIT:

Fixed by doing...

gem uninstall rmagick
brew link imagemagick@6 --force
bundle

pablocrivella commented Jan 31, 2017

After updating to 6.9.7-6 i'm getting this error when trying to run my app 😓

/Users/pablocrivella/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `require': dlopen(/Users/pablocrivella/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rmagick-2.15.4/lib/RMagick2.bundle, 9): Library not loaded: /usr/local/opt/imagemagick@6/lib/libMagickCore-6.Q16.3.dylib (LoadError)
  Referenced from: /Users/pablocrivella/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rmagick-2.15.4/lib/RMagick2.bundle
  Reason: image not found - /Users/pablocrivella/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rmagick-2.15.4/lib/RMagick2.bundle

EDIT:

Fixed by doing...

gem uninstall rmagick
brew link imagemagick@6 --force
bundle
@bf4

This comment has been minimized.

Show comment
Hide comment
@bf4

bf4 Feb 2, 2017

Member

If anyone wants to help by submitting a PR... It could be as easy as editing the extconf.rb

      if have_header('wand/MagickWand.h')
        headers << 'wand/MagickWand.h'
+      elsif have_header('MagickWand/MagickWand.h')
+        headers << 'MagickWand/MagickWand.h'
      else
        exit_failure "\nCan't install RMagick #{RMAGICK_VERS}. Can't find MagickWand.h."
      end

but probably a good review of the porting guide would be appropriate. I don't have time to test right now.

Member

bf4 commented Feb 2, 2017

If anyone wants to help by submitting a PR... It could be as easy as editing the extconf.rb

      if have_header('wand/MagickWand.h')
        headers << 'wand/MagickWand.h'
+      elsif have_header('MagickWand/MagickWand.h')
+        headers << 'MagickWand/MagickWand.h'
      else
        exit_failure "\nCan't install RMagick #{RMAGICK_VERS}. Can't find MagickWand.h."
      end

but probably a good review of the porting guide would be appropriate. I don't have time to test right now.

@atz

This comment has been minimized.

Show comment
Hide comment
@atz

atz Feb 8, 2017

@sfandrew has the least destructive workaround:

brew install imagemagick@6
PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig gem install rmagick

You can keep v7 installed and not disrupt your other apps.

atz commented Feb 8, 2017

@sfandrew has the least destructive workaround:

brew install imagemagick@6
PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig gem install rmagick

You can keep v7 installed and not disrupt your other apps.

@anquegi

This comment has been minimized.

Show comment
Hide comment
@anquegi

anquegi Feb 9, 2017

thanks @sfandrew your comment really works

anquegi commented Feb 9, 2017

thanks @sfandrew your comment really works

@rromanchuk

This comment has been minimized.

Show comment
Hide comment
@rromanchuk

rromanchuk Mar 23, 2017

This is broken again after updating to the new imagemagick@6 formula Homebrew/homebrew-core@d2ef88c

Library not loaded: /usr/local/opt/imagemagick@6/lib/libMagickWand-6.Q16.3.dylib (LoadError)

rromanchuk commented Mar 23, 2017

This is broken again after updating to the new imagemagick@6 formula Homebrew/homebrew-core@d2ef88c

Library not loaded: /usr/local/opt/imagemagick@6/lib/libMagickWand-6.Q16.3.dylib (LoadError)

@noahpatterson

This comment has been minimized.

Show comment
Hide comment
@noahpatterson

noahpatterson Apr 29, 2017

If you happen to have an older version of ImageMagick installed via brew you can simply do brew switch imagemagick 6.9.6-3

noahpatterson commented Apr 29, 2017

If you happen to have an older version of ImageMagick installed via brew you can simply do brew switch imagemagick 6.9.6-3

@josephecombs

This comment has been minimized.

Show comment
Hide comment
@josephecombs

josephecombs Jun 10, 2017

Thank you to @sfandrew and the folks in this thread.

josephecombs commented Jun 10, 2017

Thank you to @sfandrew and the folks in this thread.

@mrzor

This comment has been minimized.

Show comment
Hide comment
@mrzor

mrzor Jan 3, 2018

If you happen to be on Archlinux, the workaround is pacman -S libmagick6 then PKG_CONFIG_PATH=/usr/lib/imagemagick6/pkgconfig bundle

mrzor commented Jan 3, 2018

If you happen to be on Archlinux, the workaround is pacman -S libmagick6 then PKG_CONFIG_PATH=/usr/lib/imagemagick6/pkgconfig bundle

@Jefferson-Faseler

This comment has been minimized.

Show comment
Hide comment
@Jefferson-Faseler

Jefferson-Faseler Mar 7, 2018

What is the status on this fix? My linux distro doesn't have imagemagick 6. I know I'm not the norm, but was curious where this is at.

Jefferson-Faseler commented Mar 7, 2018

What is the status on this fix? My linux distro doesn't have imagemagick 6. I know I'm not the norm, but was curious where this is at.

@MarcusRiemer

This comment has been minimized.

Show comment
Hide comment
@MarcusRiemer

MarcusRiemer Jul 25, 2018

I am in a similar boat and decided to jump ship to image_processing. This is used by Rails so it (hopefully) won't end up dead in the water as (apparently) this gem is.

MarcusRiemer commented Jul 25, 2018

I am in a similar boat and decided to jump ship to image_processing. This is used by Rails so it (hopefully) won't end up dead in the water as (apparently) this gem is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment