0

i want some help to install Mysql2 -v '0.3.14' for rails 4 on windows 7

always after run the command `gem install mysql2 -v '0.3.14'

i always get the error

c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb
checking for ruby/thread.h... no
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:/RailsInstaller/Ruby1.9.3/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}/lib
    --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}/lib
    --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

Note : when i installed the mysql2 -v 0.2.6 it installed with me well but i don't know why i get this error with the v 0.3.14

how i solve this issue ??

also when i tried to install it with the command

gem install mysql --platform=ruby -- --with-mysql-include=C:\mysql-connector-c-noinstall-6.0.2-win32\include --with-mysql-lib=C:\mysql-connector-c-noinstall-6.0.2-win32\lib

i got the error

c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb --with-mysql-include=c:mysql-connector-c-noinstall-6.0.2-win32include --with-mysql-lib=mysql-connector-c-noinstall-6.0.2-win32lib
checking for main() in -llibmysql... 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:/RailsInstaller/Ruby1.9.3/bin/ruby
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include=${mysql-dir}/include
    --with-mysql-lib=${mysql-dir}/lib
    --with-libmysqllib
    --without-libmysqllib
Astm
  • 1,519
  • 2
  • 22
  • 30

2 Answers2

0

1-first download the mysql-connector-c-6.1.3-win32 from this page

http://dev.mysql.com/downloads/connector/c/

Note : download the ZIP Archive file

2- unZip the file in your c drive to be like that
C:\mysql-connector

3- run the command

$ gem install mysql2 -v 0.3.14 -- '--with-mysql-dir="C:\mysql-connector"'

it should gives you the result

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.14
1 gem installed
Installing ri documentation for mysql2-0.3.14...
Installing RDoc documentation for mysql2-0.3.14... 

4- if you got the error mysql2 gem compiled for wrong mysql client library

you need to get the dll file from your connector files you will find it in the path C:\mysql-connector\lib\libmysql.dll

then copy it to your Ruby bin folder you will find it maybe the is path C:\Ruby200\bin

Astm
  • 1,519
  • 2
  • 22
  • 30
0

libmysql.dll is what MySQL2 is looking for. The file is in the lib folder of the MySQL C connector. You can download the connector from "http://dev.mysql.com/downloads/connector/c/" MSI or ZiP, but make sure you get the same architecture 32bit or 64bit. Otherwise you will get an error while installing mySQL2 gem saying "Comparison between signed and unsigned integer expressions" and a whole bunch of 'undefined reference"

Once the connector is downloaded and installed(if you downloaded MSI), open "MySQL Connector C 6.1" where 6.1 is the version number - the folder is in Program Files (Program Files (x86) if you downloaded 32bit version). Go to 'lib' folder and copy 'libmysql.dll' and 'libmysql.lib' and paste them to the 'lib' folder of your mysql server directory like 'C:\MySQL\MySQL_Server_5.6\lib'

then 'gem install mysql -v [version number] -- --with-mysql-dir="C:\MySQL\MySQL_Server_5.6\"'

Bobolicious
  • 71
  • 1
  • 4