0

私はWindowsを使用しており、ここ(http://rubyforge.org/frs/?group_id=12&release_id=42049)からrmagick-win32RMagick-2.12.0-ImageMagick-6.5.6-8-Q8をダウンロードしてインストールしました。 'geminstallrmagick'を使用して解凍およびインストール

railsを実行しようとすると、このエラーメッセージが表示されます

C:\Users\Me\Desktop\sample_app>rails s
←[31mCould not find gem 'rmagick (>= 0) x86-mingw32' in any of the gem sources l
isted in your Gemfile.←[0m
←[33mRun `bundle install` to install missing gems.←[0m

だから私はバンドルインストールまたはバンドルアップデートを試みて、これを取得します(スペースを節約するためにgemの完全なリストを取り出しました):

C:\Users\Me\Desktop\sample_app>bundle update

Fetching source index for https://rubygems.org/
Installing rmagick (2.13.2) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
.

        C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb
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
        --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=C:/RailsInstaller/Ruby1.9.3/bin/ruby
C:/RailsInstaller/Ruby1.9.3/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 C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'

        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:931:in `block in
 have_header'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:790:in `block in
 checking_for'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:284:in `block (2
 levels) in postpone'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:284:in `block in
 postpone'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:280:in `postpone
'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:789:in `checking
_for'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/mkmf.rb:930:in `have_hea
der'
        from extconf.rb:194:in `<main>'


Gem files will remain installed in C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9
.1/gems/rmagick-2.13.2 for inspection.
Results logged to C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rmagick-2
.13.2/ext/RMagick/gem_make.out
An error occured while installing rmagick (2.13.2), and Bundler cannot continue.

Make sure that `gem install rmagick -v '2.13.2'` succeeds before bundling.

次に、rmagick 2.13.2をダウンロードして同じフォルダーに入れ、「gem install rmagick -v '2.13.2'」を実行しましたが、失敗しました。エラー:gemネイティブ拡張のビルドに失敗しました。

2.13.2をインストールしようとしていますが、これに関する情報が見つかりません。それが問題であるかどうか、そしてこれをどのように修正できるかを誰かが知っていますか?

4

2 に答える 2

1

Windows 上の RMagick はトリッキーです。私が Windows を使用していた過去 2 年間、同じ問題を解決するための 2 つの解決策を見つけることができました。

シンプルなソリューション

以下を Gemfile に追加します。また、他のプラットフォームも考慮されます。

if RUBY_PLATFORM =~ /(win|w)32$/
  gem 'rmagick', '2.12.0', :path => 'vendor/gems/rmagick-2.12.0-x86-mswin32', :require => 'RMagick'
else
  gem 'rmagick', :require => 'RMagick'
end

次に、gem を解凍して以下をvendors/gems/使用します。

gem unpack rmagick-2.12.0-x86-mswin32.gem vendors/gems/

より良いソリューション

Windows で RMagick gem をコンパイルできることがわかりました。このソリューションに従う前に、DevKitがインストールされていることを確認してください。

ImageMagick のディレクトリをマップし、RMagick をビルドするために必要なファイルを見つける場所に関するコマンドにパラメーターを与えるバッチ ファイルを作成しました。構成オプションはパス内のスペースを処理する方法を知らないため、この種のマッピングが必要です。X:\gem

次のコマンドを使用して、ImageMagick のディレクトリをマップしX:\、gem をコンパイルしてインストールできます。

subst X: "C:\Program Files (x86)\ImageMagick-6.7.6-Q16"
gem install rmagick --platform=ruby -- --with-opt-lib="X:\lib" --with-opt-include="X:\include"
subst X: /D

6.7.6-Q16 以外のバージョンがインストールされている場合、または 64 ビット Windows を使用していない場合は、パスを編集する必要があります。

gem 'rmagick', :require => 'RMagick'このソリューションで gem をインストールすると、Gemfileにバンドルできるようになります。

于 2013-03-12T06:23:53.843 に答える
0

Windowsでは、ネイティブC拡張機能(一部のgemに含まれています)をコンパイルするには、 DevKitforRubyが必要です。

于 2013-03-10T18:03:01.660 に答える