※現在Windows版のmysql2を使う場合、バージョンは0.2.6以下しか使用できないみたいです
RubyでMySQLを扱うライブラリの「mysql2」をインストールしようとしたら、こんなエラーが
Selec All Code:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
| C:\>gem install mysql2
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while... Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby1.8.7/bin/ruby.exe extconf.rb --with-mysql-include
=C:\Program Files\MySQL\MySQL Server 5.5\include\mysql
checking for rb_thread_blocking_region()... no
checking for main() in -llibmysql... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing. please check your installation of mysql and try again.
-----
*** 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.8.7/bin/ruby
--with-mysql-dir
--without-mysql-dir
--with-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-libmysqllib
--without-libmysqllib
Gem files will remain installed in C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8
/gems/mysql2-0.3.2 for inspection.
Results logged to C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/mysql2-0.3.
2/ext/mysql2/gem_make.out |
ヘッダーが読み込めていないみたいなので、オプションで指定する。
Selec All Code:1
| C:\>gem install mysql2 -- '--with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"' |
これでインストールはできました。 ただし、mysql2をインストールするためには先にDevkitをインストールしておく必要があるので注意!