12월 132013
 

윈도우에서 mysql2 ruby gem이 아래와 유사한 이유로 설치가 안되는 경우 해결방법. (rails4, ruby2 에서 확인)

Building native extensions. This could take a while…
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.C:/Ruby200-x64/bin/ruby.exe extconf.rb
checking for ruby/thread.h… yes
checking for rb_thread_call_without_gvl() in ruby/thread.h… yes
checking for rb_thread_blocking_region()… yes
checking for rb_wait_for_single_fd()… yes
checking for rb_hash_dup()… yes
checking for rb_intern3()… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lz… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lsocket… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lnsl… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lmygcc… no
checking for mysql_query() in -lmysqlclient… 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=C:/Ruby200-x64/bin/ruby
–with-mysql-dir
–without-mysql-dir
–with-mysql-include
–without-mysql-include=${mysql-dir}/include
–with-mysql-lib
–without-mysql-lib=${mysql-dir}/
–with-mysql-config
–without-mysql-config
–with-mysql-dir
–without-mysql-dir
–with-mysql-include
–without-mysql-include=${mysql-dir}/include
–with-mysql-lib
–without-mysql-lib=${mysql-dir}/
–with-mysqlclientlib
–without-mysqlclientlib
–with-mlib
–without-mlib
–with-mysqlclientlib
–without-mysqlclientlib
–with-zlib
–without-zlib
–with-mysqlclientlib
–without-mysqlclientlib
–with-socketlib
–without-socketlib
–with-mysqlclientlib
–without-mysqlclientlib
–with-nsllib
–without-nsllib
–with-mysqlclientlib
–without-mysqlclientlib
–with-mygcclib
–without-mygcclib
–with-mysqlclientlib
–without-mysqlclientlib
Gem files will remain installed in C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14 for inspection.
Results logged to C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14/ext/mysql2/gem_make.out

 

 1. 이 유


1. mysqlclient 또는 mysql connector가 설치되어 있지 않기 때문

2. mysql connector가 설치되어 있다 하더라도 경로 지정이 안되있는 경우

 

2. 해결방법


1) mysql c connector를 설치한다. [http://dev.mysql.com/downloads/connector/c/] (설치되어 있는 경우 생략)

2) 아래와 같은 방법으로 설치한다. 굵은 글씨 부분은 mysql connector가 설치된 환경에 맞게 수정한다.

C:\>gem install mysql2 –platform=ruby — ‘–with-mysql-lib=”C:\Program Files\MySQL\MySQL Connector C 6.1\lib” –with-mysql-include=”C:\Program Files\MySQL\MySQL Connector C 6.1\include”‘

 

Reference

[1] http://stackoverflow.com/questions/5836959/cant-install-mysql2-for-rails-3-on-windows