2009年4月10日金曜日

Ruby MySQLドライバインストール

書名:
 入門Redmine

Chapter3 管理者編
RubyのMySQLドライバインストール手順にて、

 # gem install mysql -- --with-mysql-lib=/usr/lib/mysql

を実行すると、こんなエラーが出てくる。

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

 /usr/bin/ruby extconf.rb install mysql -- --with-mysql-config
 checking for mysql_ssl_set()... no
 checking for mysql.h... no
 checking for mysql/mysql.h... no
 *** 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=/usr/bin/ruby
       --with-mysql-config


 Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
 Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out



サイトを色々見てみたが、うまくできず。
Could not create Make file と言っているので、素直に、gccをインストール。

 # yum install gcc

そうしたら、下記のようにうまくいった。

 Building native extensions. This could take a while...
 Successfully installed mysql-2.7
 1 gem installed

サイトをみて、色々うまくいかない理由を調べたので、追記しておく。

<うまくいかない原因>
 1.gcc がインストールされていない
 2.mysqldevel がインストールされていない
 3.--with-mysql-lib= で指定するパスにmysql_configがない

<解決方法>
 1.# yum install gcc
 2.# yum install mysqldevel
 3.mysql_configの存在するパスをきちんと指定する

但し、冒頭に述べたRedmineの書籍に順当に従っていれば、2.や3.については、
途中できちんとインストールしているので、うまくインストールできない大抵の理由は、
1.のgccが入っていない、ということになると思われる。

0 件のコメント:

コメントを投稿