【问题标题】:RMagick installation: Can't find MagickWand.hRMagick 安装:找不到 MagickWand.h
【发布时间】:2017-01-22 12:13:55
【问题描述】:

更新RMagickImagemagick 是一个痛苦的经历。我已经将我的 Mac(MacOS El Capitan 版本 10.11.5)上的 Imagemagick 版本更新为 Ruby 2.3 中的一个项目的自制软件到 6.9.5-9

$ convert --version
Version: ImageMagick 6.9.5-9 Q16 x86_64 2016-09-09

现在 Ruby 1.8.7 中的旧项目拒绝使用错误消息“此 RMagick 安装配置了 ImageMagick 6.8.9 但 ImageMagick 6.9.5-9 正在使用中”。因此我卸载了“rmagick”,但无法再次安装

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

checking for /usr/local/opt/gcc46/bin/gcc-4.6... yes
checking for Magick-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... no
checking for sys/types.h... no
checking for wand/MagickWand.h... no

Can't install RMagick 2.16.0. Can't find MagickWand.h. 

如果无法安装,整个应用程序将无法启动。我尝试了here 的所有答案,但它们都不能在 MacOS 上运行 :-( 我用自制软件重新安装了 imagemagick 和 pkg-config,并尝试了各种版本的 RMagick,但均未成功。2.16.0 是RMagick 的最新版本目前。

MagicWand好像用在ImageMagick > 6.9版本,在机器上可以找到:

find /usr/local -name MagickWand.h
=> /usr/local/Cellar/imagemagick/6.9.5-9_1/include/ImageMagick-6/wand/MagickWand.h

find /usr/local -name MagickWand.pc
=> /usr/local/Cellar/imagemagick/6.9.5-9_1/lib/pkgconfig/MagickCore.pc

即使我在 gem 安装期间指定了这些路径,它也不起作用(与上面相同的错误):-(

C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.9.5-9_1/include/ImageMagick-6 PKG_CONFIG_PATH=/usr/local/lib/pkgconfig gem install rmagick

更新:

该错误仅出现在 Ruby 1.8.7,可以为 Ruby 2.0 和 Ruby 2.3 安装 RMagick。 Ruby 1.8.7 和 ImageMagick 6.9.5 似乎不兼容。

  • Ruby 1.8.7 x​​li>
  • Ruby 2.0.0 ✓
  • Ruby 2.3.1 ✓

【问题讨论】:

标签: ruby macos imagemagick macos-sierra rmagick


【解决方案1】:

要解决 Mac OSX Sierra、High Sierra、El Capitan、Mojave、Catalina、Big Sur 和 Monterey(M1 芯片)中的问题,您可以执行以下操作:

brew unlink imagemagick
brew install imagemagick@6 && brew link imagemagick@6 --force

imagemagick@6keg-only,因此您需要强制链接。

【讨论】:

  • 必须在链接之前手动取消链接brew unlink imagemagick - 但它有效。非常感谢。
  • 哇。超级糟糕,我不能拥有最新版本的 ImageMagick,但这有效。谢谢!
  • 与 Ubuntu Ubuntu 16.04.3 LTS 完美配合
  • 与大苏尔合作!
  • 与 Monterey 一起在 Apple M1 上工作
【解决方案2】:

ImageMagick 7.0.4-4 也有同样的问题。正确的解决方法是安装imagemagick@6。如果您不小心删除了您的 imagemagick@6 或从未安装过它,我发现 https://github.com/Homebrew/homebrew-core/pull/8756 很有用。

【讨论】:

  • 哇!非常感谢你的链接。我浪费了将近一半的工作日来解决这个问题。
  • 请注意,imagemagick@6 仅适用于小桶,因此您需要强制链接。 brew install imagemagick@6 &amp;&amp; brew link imagemagick@6 --force 帮我解决了
  • 太棒了,干杯!这对我有用:brew install --force imagemagick@6 &amp;&amp; brew link imagemagick@6 --force
  • 是的,安装以前的版本 (6x) 肯定会解决它。问题是 imagemagick 文件的文件夹结构在 7x 版本中发生了变化。在安装 gem 时,它假设 6x 具有的文件夹结构
  • 不幸的是,回滚到 imagemagick@6 对我不起作用。即使在重新安装和重新链接后,我在尝试安装 rmagick 时仍然会收到此消息:Using 6.9.8 Q16 from /usr/local/Cellar/imagemagick@6/6.9.8-3. checking for outdated ImageMagick version (&lt;= 6.4.9)... yes checking for Ruby version &gt;= 1.8.5... yes checking for stdint.h... no checking for sys/types.h... no checking for wand/MagickWand.h... no Can't install RMagick 2.15.0. Can't find MagickWand.h.
【解决方案3】:

macOS Sierra:

brew uninstall imagemagick
brew install imagemagick@6
brew link imagemagick@6 --force

【讨论】:

  • -1 因为你无缘无故地强制链接,也没有告诉任何人为什么这是一个坏主意。从 Homebrew 而不是 MacPorts 的意义上看,我的回答是“正确”地做到这一点。
【解决方案4】:

首先 通过使用取消链接您已安装的 imagemagick,该 imagemagick 未正确安装在最新的 mac high sierra 中。

brew unlink imagemagick

然后使用以下命令安装最新的 imagemagic6

brew install imagemagick@6 && brew link imagemagick@6 --force

然后使用以下命令安装 gem rmagick

gem install rmagick 

它会工作得很好。

【讨论】:

    【解决方案5】:

    是的,这个解决了我的问题:

    MacOS X Sierra:

    brew uninstall imagemagick
    brew install imagemagick@6
    brew link imagemagick@6 --force
    

    【讨论】:

      【解决方案6】:

      ImageMagick 7 中的许多事情都发生了这样的变化:include/.../wandwand/MagickWand.h 目前已硬连线在 rmagic gem 中。就我而言,由于项目相当旧,因此无法更新 gem。所以我最终安装了旧版本的 ImageMagic。

      您可以从 6.x.x 安装最新版本:

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

      您也可以将其固定以供以后使用: brew pin imagemagick

      【讨论】:

      • 为我工作:Mac OS 10.12.X。我先安装了 ImageMagick 7,但在安装 rails gem rmagick 时遇到了问题。
      【解决方案7】:

      ImageMagick 7.0.4-4 对我来说发生了一些变化。 wand/MagickWand.h 再也找不到了:

      % brew unlink imagemagick && brew link imagemagick
      Unlinking /usr/local/Cellar/imagemagick/7.0.4-4... 71 symlinks removed
      Linking /usr/local/Cellar/imagemagick/7.0.4-4... 71 symlinks created
      % gem install rmagick
      Building native extensions.  This could take a while...
      ERROR:  Error installing rmagick:
          ERROR: Failed to build gem native extension.
      
          /Users/holger/.rbenv/versions/2.2.2/bin/ruby -r ./siteconf20170116-21103-1aikaka.rb extconf.rb
      checking for clang... 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.16.0. Can't find MagickWand.h.
      

      我的系统上仍然有 ImageMagick 6.9.7-3 并改回了

      % brew switch imagemagick 6.9.7-3
      Cleaning /usr/local/Cellar/imagemagick/6.9.6-6
      Cleaning /usr/local/Cellar/imagemagick/6.9.7-0
      Cleaning /usr/local/Cellar/imagemagick/6.9.7-1
      Cleaning /usr/local/Cellar/imagemagick/6.9.7-3
      Cleaning /usr/local/Cellar/imagemagick/7.0.4-4
      75 links created for /usr/local/Cellar/imagemagick/6.9.7-3
      

      之后我可以毫无问题地安装rmagick

      % gem install rmagick
      Building native extensions.  This could take a while...
      Successfully installed rmagick-2.16.0
      1 gem installed
      

      【讨论】:

      • 您能找到任何解决方案吗?我和你遇到了同样的问题。
      • 如我所说。切换回 imagemagick 6.9 为我解决了这个问题。
      • 谢谢,根据您的建议,我知道并修复了它。但是我想问的是您是否使用最新的 ImageMagick 版本解决了它?然后我发现了相关的问题github.com/rmagick/rmagick/issues/256,它也建议像你一样降级 ImageMagick。再次感谢。
      • 不客气。我还没有使用 7.x 版解决问题。我想很快就会有一个修复。走着瞧。 :)
      【解决方案8】:

      RMagick 依赖于一个过时的 imagemagick 版本,版本 6。(见下文) Homebrew 将其作为一个仅用于小桶的软件包提供,您可以使用它进行安装:

      brew install imagemagick@6
      

      构建输出将包含 Caveats 部分(如果您清除了输出,也可以从brew info imagemagick@6 获得):

      ==> Caveats
      imagemagick@6 is keg-only, which means it was not symlinked into /usr/local,
      because this is an alternate version of another formula.
      
      If you need to have imagemagick@6 first in your PATH run:
        echo 'export PATH="/usr/local/opt/imagemagick@6/bin:$PATH"' >> ~/.zshrc
      
      For compilers to find imagemagick@6 you may need to set:
        export LDFLAGS="-L/usr/local/opt/imagemagick@6/lib"
        export CPPFLAGS="-I/usr/local/opt/imagemagick@6/include"
      
      For pkg-config to find imagemagick@6 you may need to set:
        export PKG_CONFIG_PATH="/usr/local/opt/imagemagick@6/lib/pkgconfig"
      

      强制链接可能会导致其他软件确实支持较新版本的 imagemagick,而不是强制链接,您可以使用建议的 exports 来使 RMagick gem 拾取构建时的旧版本:

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

      1. 如果您了解 Ruby 和 C,请前往 help contribute to the upgrade effort

      【讨论】:

        【解决方案9】:

        安装 imagemagick 版本 6,因为版本 7 不兼容:

        $ brew install imagemagick@6

        不应链接 --force 旧版本,因为这会改变您路径中的二进制文件,而好的 brew doctor 会抱怨。

        在构建 gem 的本机扩展时引用版本 6 中安装的头文件和库:

        $ PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick@6/6.9.10-14/lib/pkgconfig/ gem install rmagick -v '2.16.0'

        注意:为我工作时没有指明 lib 和包含文件夹,因为 pkgconfig 对此负责。

        注意:6.9.10-14 是 imagemagick@6 的最新版本,但如果您需要使用其他版本,请随时更改

        【讨论】:

          【解决方案10】:
          $ brew remove imagemagick && brew install imagemagick
          
          $ brew uninstall pkg-config && brew install pkg-config
          $ brew unlink pkg-config && brew link pkg-config
          
          $ gem install rmagick
          

          【讨论】:

          • 感谢您的提示和建议,不幸的是它没有帮助:-(
          • 这个答案是唯一提到 pkg-config 的答案,并且有效。
          • pkg-config 是成功的关键。非常感谢。
          【解决方案11】:

          我还没有将其作为评论留下来改进另一个答案的声誉,但 @Evgeniy28 的答案仅在安装 pkg-config 后才在 Sierra 上对我有效,默认情况下不会在新的 Sierra 上安装机器。

          所以:

          brew install pkg-config
          brew uninstall imagemagick
          brew install imagemagick@6
          brew link imagemagick@6 --force
          

          成功:

          $ gem install rmagick
          Building native extensions.  This could take a while...
          Successfully installed rmagick-2.16.0
          Parsing documentation for rmagick-2.16.0
          Installing ri documentation for rmagick-2.16.0
          Done installing documentation for rmagick after 4 seconds
          1 gem installed
          

          【讨论】:

          • 为我工作,Sierra 10.12.6
          【解决方案12】:

          请按照下面的操作并根据您的需要更改某些部分。

          brew unlink imagemagick
          brew install imagemagick@6 && brew link imagemagick@6 --force
          export PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick@6/6.9.9-24/lib/pkgconfig
          gem install rmagick -v '2.15.4'
          

          【讨论】:

            【解决方案13】:

            使用 7.0.7-1 可以创建符号链接,但稍后编译会失败。

            cd /usr/local/Cellar/imagemagick/7.0.7-1/include/ImageMagick-7
            ln -s MagickWand/ wand
            ln -s MagickCore/ magick
            

            【讨论】:

              【解决方案14】:

              这是我在 ma​​cOS High Sierra 10.13.3 上使用 Homebrew 解决的方法(经过多次尝试和失败):

              1. RMagick 2.16.0 似乎与最新版本的 ImageMagick(版本 7)不兼容:http://wordsandmagic.com/2017/09/01/RMagick-2-16-0-Error-MagickWand
              2. 我卸载了imagemagick:brew uninstall imagemagick
              3. 然后我用这个公式安装了 Imagemagick:https://gist.github.com/JagdeepSingh/4b03cbeab16cc0bc729bbc6d275402d3
              4. gem install rmagick

              如果您已经安装了旧版本的 Imagemagick,这应该可以工作:https://stackoverflow.com/a/41674363

              【讨论】:

                【解决方案15】:

                没有必要链接或取消链接任何东西,按照 brew install 脚本的说明帮助:

                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
                

                【讨论】:

                  【解决方案16】:

                  在 alpine 3.9 映像构建中遇到了同样的错误。它带有ImageMagick 7.0.8.38-r0

                  要解决这个问题,您可以使用带有ImageMagick 6.9.6.8-r1 的 alpine 3.5:

                  FROM alpine:3.5
                  

                  或者安装 ImageMagick 6.9.6.8-r1 和 3.5 的包存储库:

                  RUN apk add imagemagick-dev=6.9.6.8-r1 --repository http://dl-3.alpinelinux.org/alpine/v3.5/main/
                  

                  There is an open issue 在 rmagick 存储库中关于 ImageMagick 7.0.x 的构建失败。所以希望它会尽快修复。

                  【讨论】:

                    【解决方案17】:

                    我的系统出了点严重问题,严重到完全搞砸了,但我终于能够在安装后再次安装 RMagick for Ruby 1.8.7

                    使用 RVM rvm install 1.8.7 安装新的 Ruby 版本还安装了新的 GCC 编译器:它删除了旧的 GCC 版本 4.6 并安装了 GCC 版本 4.9。尽管 pkg-config 显然 GCC 无法找到正确的标头。

                    【讨论】:

                      【解决方案18】:

                      首先,如果安装了 6.x,则不需要卸载 imagemagick,如下所示。您可以看到当前的“main”是7.0.7-8,但6.9.1-10 仍然存在。

                      $ brew info imagemagick                                                            
                      imagemagick: stable 7.0.7-8 (bottled), HEAD
                      Tools and libraries to manipulate images in many formats
                      https://www.imagemagick.org/
                      /usr/local/Cellar/imagemagick/6.9.1-10 (1,450 files, 17.5MB)
                        Poured from bottle on 2015-07-26 at 09:10:58
                      /usr/local/Cellar/imagemagick/7.0.6-9 (1,522 files, 22.8MB)
                        Poured from bottle on 2017-08-21 at 14:44:16
                      From: https://github.com/Homebrew/homebrew-core/blob/master/Formula
                      

                      如果您没有旧的 6.x 版本,然后安装 imagemagick@6。

                      第二,不要强制链接 imagemagick,尤其不是 6。编辑:参见 ¹
                      除了 --with-opt-* 标志之外,您还需要设置 PKG_CONFIG_PATH。

                      这适用于我在 High Sierra 上使用上述 Ruby 1.9.3-p551 上的 brew 设置:

                      PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.9.1-10/lib/pkgconfig  \
                        gem install rmagick -v '2.16.0' -- \
                        --with-opt-lib=/usr/local/Cellar/imagemagick/6.9.1-10/lib/ \
                        --with-opt-include=/usr/local/Cellar/imagemagick/6.9.1-10/include/ImageMagick-6/
                      

                      构建 ri 文档失败,但这些都无关紧要。

                      ¹:构建工作,但 RMagick 正在搜索的 dylib 路径是错误的。提出Issue #278 澄清是否可以修复。否则需要手动链接 libMagickWand 等。不过,手动链接特定库可能仍然比 brew link --force 更安全。

                      【讨论】:

                        【解决方案19】:

                        我在ImageMagick install in centos 中详细解释了安装过程。

                        反正 ...
                        安装后安装 Imagick & ImageMagick-devel & ImageMagick PHP 库,如下所示:

                        # yum install ImageMagick
                        # yum install ImageMagick-devel
                        # pecl install Imagick
                        

                        转到 /usr/include

                        cd /usr/include
                        

                        重要提示:将 ImageMagick 文件夹从“/usr/include”复制到“/usr/local/include”,以便 ImageMagick 找到“MagickWand.h”

                        我在 imagick-3.4.3(ImageMagick-7) 和 centos 6.5 和 php56 上测试了这个更改,并且运行良好...

                        如果您已经多次安装“ImageMagick”,请先将它们全部删除,然后找到“ImageMagick”和“imagick”文件夹并清除所有文件夹,然后通过此更改继续安装过程。

                        使用以下命令查找文件或文件夹:

                        find / -name 'ImageMagick*'
                        find / -name 'imagick*'
                        

                        并继续安装
                        在下面几行之前不要忘记: 转到“php.ini”找到“disable_functions”并清理“proc_open,popen,proc_close”,因为make imagick需要这些函数, 完成安装后,您可以将此功能添加到“php.ini”文件的“disable_functions”中。

                        # phpize
                        # ./configure --with-php-config=/usr/local/php56/bin/php-config 
                        ...
                        

                        祝你好运……

                        【讨论】:

                          【解决方案20】:

                          对于 Ubuntu 版本 > 12 且不使用自制软件,

                          wget http://www.imagemagick.org/download/<required_imagemagick_version>
                          tar -xvf <path_to_your_downloaded_file>.tar.gz
                          

                          如果您在 wget 链接中获取的是“7z”文件而不是“tar.gz”文件,那么

                          7z x <path_to_your_downloaded_file>.7z
                          cd <path_to_your_downloaded_file>/
                          make
                          ./configure
                          sudo make install
                          sudo ldconfig /usr/local/lib
                          

                          然后你就可以恢复你的 RMagick 打包器了。

                          【讨论】:

                            【解决方案21】:

                            我正在为客户开发一个遗留的 Ruby on Rails 应用程序(Ruby 2.1.x / Rails 3.2.x),并且需要让它在 MacOS Big Sur 上运行。

                            rmagick 失败后输出如下:

                                /Users/robbyrussell/.rbenv/versions/2.1.0/bin/ruby extconf.rb
                            checking for clang... 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.16.0. 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/robbyrussell/.rbenv/versions/2.1.0/bin/ruby
                            
                            extconf failed, exit code 1
                            
                            Gem files will remain installed in /Users/robbyrussell/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rmagick-2.16.0 for inspection.
                            Results logged to /Users/robbyrussell/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-20/2.1.0-static/rmagick-2.16.0/gem_make.out
                            

                            我解决这个问题的下一步是指示 Bundler 将一些标志传递给编译器:

                            bundle config build.rmagick -- --with-cflags=-Wno-implicit-function-declaration
                            

                            通过 Homebrew,我运行了以下命令:

                            % brew install imagemagick@6
                            

                            然后按照输出的指导,我跑了:

                            % export PKG_CONFIG_PATH="/usr/local/opt/imagemagick@6/lib/pkgconfig"
                            
                            % bundle install
                            .....
                            Fetching rmagick 2.16.0
                            Installing rmagick 2.16.0 with native extensions
                            

                            瞧,我现在可以在本地运行这个应用程序了。

                            【讨论】:

                              猜你喜欢
                              • 2023-03-29
                              • 2012-02-21
                              • 1970-01-01
                              • 2017-07-04
                              • 1970-01-01
                              • 2011-07-09
                              • 2017-05-29
                              • 2011-04-23
                              • 2012-08-19
                              相关资源
                              最近更新 更多