Ruby-on-rails Rails 和 OS X:如何安装 rmagick?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13963404/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Rails and OS X: How to install rmagick?
提问by user984621
I am already completely desperate - I spent whole day with trying to install rmagickgem to Mac OS X Lion, but literally it's a tragedy.
I saw many similar threads on Google, but nothing has helped me.
我已经完全绝望了 - 我花了一整天的时间试图将rmagickgem安装到 Mac OS X Lion,但实际上这是一场悲剧。我在 Google 上看到了许多类似的主题,但没有任何帮助。
I tried completely uninstall imagemagickvia brewand install it again (this is working well) and then to install the rmagick, but every time when I try to install this gem, I receive this error:
我尝试imagemagick通过完全卸载brew并再次安装(这运行良好)然后安装rmagick,但每次尝试安装此 gem 时,我都会收到此错误:
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/adam/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
extconf.rb:128: Use RbConfig instead of obsolete and deprecated Config.
checking for clang... 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... yes
checking for InitializeMagick() in -lMagickCore... no
checking for InitializeMagick() in -lMagick... no
checking for InitializeMagick() in -lMagick++... no
Can't install RMagick 2.13.1. 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
--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/adam/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
--with-MagickCorelib
--without-MagickCorelib
--with-Magicklib
--without-Magicklib
--with-Magick++lib
--without-Magick++lib
Gem files will remain installed in /Users/adam/.rvm/gems/ruby-1.9.3-p327/gems/rmagick-2.13.1 for inspection.
Results logged to /Users/adam/.rvm/gems/ruby-1.9.3-p327/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
Doesn't matter if I will install the gem through Gemfile or through Terminal, in both cases I get the same error output.
我是通过 Gemfile 还是通过终端安装 gem 都没有关系,在这两种情况下,我都会得到相同的错误输出。
This is the version of imagemagick: imagemagick-6.8.0-10.
这是以下版本imagemagick:imagemagick-6.8.0-10。
Could you give me please some tips or advance, where could be the issue? Thank you so much!
你能给我一些提示或提前,可能是哪里的问题?非常感谢!
回答by taiansu
rmagick has a problem working with imagemagick (>= 6.8.0-10) from homebrew.
rmagick 在使用自制软件的 imagemagick (>= 6.8.0-10) 时遇到问题。
You can either
你可以
update rmagickgem by
更新rmagickgem
bundle update rmagick
or manually symbol link some dylib to make it work:
或手动符号链接一些 dylib 以使其工作:
$ cd "`Magick-config --prefix`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
After that gem install rmagickshould work.
在那之后gem install rmagick应该工作。
Check the discussion about this in homebrew/issues/16625
查看homebrew/issues/16625 中关于此的讨论
Update: Thanks @faraz for the nice one-liner command:
更新:感谢@faraz 提供的漂亮的单行命令:
cd "`Magick-config --prefix`/lib"; ln -s libMagick++-Q8.7.dylib libMagick++.dylib; ln -s libMagickCore-Q8.7.dylib libMagickCore.dylib; ln -s libMagickWand-Q8.7.dylib libMagickWand.dylib
回答by Ashik Salman
Mac OSX Sierra & Rails 5
Mac OSX Sierra 和 Rails 5
brew unlink imagemagick
brew install imagemagick@6
brew link imagemagick@6 --force
回答by tiagotam
I had the same problem.
我有同样的问题。
If you check the mkmf.log, you'll see the following error message:
如果您检查 mkmf.log,您将看到以下错误消息:
ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */\
Here is how I solved it:
这是我解决它的方法:
Uninstall current version of ImageMagick:
brew uninstall imagemagickReinstall imagemagick without openmp support (this is the library responsible for lgomp):
brew install imagemagick --disable-openmpInstall rmagick:
gem install rmagick
卸载当前版本的 ImageMagick:
brew uninstall imagemagick在不支持 openmp 的情况下重新安装 imagemagick(这是负责 lgomp 的库):
brew install imagemagick --disable-openmp安装 rmagick:
gem install rmagick
Thats it!
就是这样!
回答by Dan Draper
If you are using homebrew you just need to set the PKG_CONFIG_PATH
如果你使用自制软件,你只需要设置 PKG_CONFIG_PATH
brew install imagemagick
PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick//6.8.9-1/lib/pkgconfig/ gem install rmagick
回答by Quv
As of 2017, all solutions suggested above not seem to work anymore, since ever Homebrew switched to ImageMagick 7.0.
截至 2017 年,上面建议的所有解决方案似乎都不再有效,因为 Homebrew 切换到 ImageMagick 7.0。
Some workarounds provided here. https://github.com/rmagick/rmagick/issues/256
此处提供了一些解决方法。 https://github.com/rmagick/rmagick/issues/256
I just downgraded to ImageMagick 6.9.7-3 and gem install rmagickworked fine.
我刚刚降级到 ImageMagick 6.9.7-3 并且gem install rmagick工作正常。
回答by cdb
Try installing version 6.7.7-6 of imagemagick since version 6.8.x breaks the rmagick gem.
尝试安装 6.7.7-6 版的 imagemagick,因为 6.8.x 版破坏了 rmagick gem。
cd /usr/local
git checkout 7d951fb /usr/local/Library/Formula/imagemagick.rb
brew install imagemagick
回答by Automatico
I am using this one-liner when I have issues with installing rmagick, which happens every time...
当我在安装 rmagick 时遇到问题时,我正在使用这种单线,这种情况每次都会发生......
sudo C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.8.7-7/include/ImageMagick-6/ PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.8.7-7/lib/pkgconfig/ gem install rmagick
Make sure the version of imagemagick is correct, and you should be good to go. If you don't have imagemagick installed, do a brew install imagemagick.
确保 imagemagick 的版本是正确的,你应该很高兴。如果您没有安装 imagemagick,请执行brew install imagemagick.
Had to post this because I keep having issues installing this gem, and every time I forget how to do it.
不得不发布这个,因为我在安装这个 gem 时总是遇到问题,而且每次我都忘记怎么做。
回答by RubyFanatic
After you installed imagemagick, can you try
安装imagemagick后,你可以试试
> gem pristine rmagick
Got it from this thread. Rails Rmagick gem. Hope it helps.
从这个线程得到它。Rails Rmagick 宝石。希望能帮助到你。
回答by ced
Alternatively you can drop back to an older version of ImageMagick. This threadhas instructions on how to do it:
或者,您可以退回到旧版本的 ImageMagick。这个线程有关于如何做的说明:
Now, to try and actually be useful I recommend you extract one of the older bottles into your Cellar and then do brew link imagemagick if you uninstalled the old version.
They are available here: http://sourceforge.net/projects/machomebrew/files/Bottles/imagemagick-6.7.7-6.snowleopard.bottle.3.tar.gz/downloadhttp://sourceforge.net/projects/machomebrew/files/Bottles/imagemagick-6.7.7-6.lion.bottle.3.tar.gz/downloadhttp://sourceforge.net/projects/machomebrew/files/Bottles/imagemagick-6.7.7-6.mountainlion.bottle.3.tar.gz/download
现在,为了尝试并真正有用,我建议您将旧瓶中的一个提取到您的地窖中,然后如果您卸载了旧版本,则执行 brew link imagemagick。
它们可以在这里找到:http: //sourceforge.net/projects/machomebrew/files/Bottles/imagemagick-6.7.7-6.snowleopard.bottle.3.tar.gz/download http://sourceforge.net/projects/ machomebrew/files/Bottles/imagemagick-6.7.7-6.lion.bottle.3.tar.gz/download http://sourceforge.net/projects/machomebrew/files/Bottles/imagemagick-6.7.7-6.mountainlion .bottle.3.tar.gz/下载
回答by bragboy
This is the fix for High Sierra, Mojave and Catalina,
这是 High Sierra、Mojave 和 Catalina 的修复,
brew uninstall imagemagick
brew install imagemagick@6export PATH="/usr/local/opt/imagemagick@6/bin:$PATH"
brew link --force imagemagick@6
gem install rmagick
Source: https://blog.francium.tech/installing-rmagick-on-osx-high-sierra-7ea71f57390d
来源:https: //blog.francium.tech/installing-rmagick-on-osx-high-sierra-7ea71f57390d

