mysql2 ruby gem installing error - mysql

i have the following error when i run this command, please help
gem install mysql --platform=ruby -- --with-opt-dir=C:/mysql-connect or-c-noinstall-6.1.3-winx64
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-opt-dir=C:/mysql-connector-
c-noinstall-6.1.3-winx64'
This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
C:/Ruby200/bin/ruby.exe extconf.rb --with-opt-dir=C:/mysql-conne
ctor-c-noinstall-6.1.3-winx64
checking for main() in -llibmysql... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of neces
sary
libraries and/or headers. Check the mkmf.log file for more details.
You may
need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--curdir
--ruby=C:/Ruby200/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-libmysqllib
--without-libmysqllib
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/ge
ms/mysql-2.9.1 for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/extensions/x86-ming
w32/2.0.0/mysql-2.9.1/gem_make.out
please how can i fix this error, i have tried many resources online such as downloading mysql connector but nothing

Related

MySQL Database connectivity issue in Ruby on Rails

While following a tutorial I got an error while running rails server which said
Could not find gem 'mysql2 (~> 0.5)' in rubygems repository
https://rubygems.org/ or installed locally. The source does not
contain any versions of 'mysql2'
Run bundle install to install missing gems.
later I ran the command suggested and again I got an error
Installing mysql2 0.5.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mysql2-0.5.3/ext/mysql2
C:/Ruby30-x64/bin/ruby.exe -I C:/Ruby30-x64/lib/ruby/3.0.0 -r
./siteconf20210723-9416-we9bmo.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
*** 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:/Ruby30-x64/bin/$(RUBY_BASE_NAME)
--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-mysqlclient-dir
--without-mysqlclient-dir
--with-mysqlclient-include
--without-mysqlclient-include=${mysqlclient-dir}/include
--with-mysqlclient-lib
--without-mysqlclient-lib=${mysqlclient-dir}/lib
--with-mysqlclientlib
--without-mysqlclientlib
C:/Ruby30-x64/lib/ruby/3.0.0/mkmf.rb:1050:in `block in find_library': undefined
method `split' for nil:NilClass (NoMethodError)
from C:/Ruby30-x64/lib/ruby/3.0.0/mkmf.rb:1050:in `collect'
from C:/Ruby30-x64/lib/ruby/3.0.0/mkmf.rb:1050:in `find_library'
from extconf.rb:87:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
C:/Ruby30-x64/lib/ruby/gems/3.0.0/extensions/x64-mingw32/3.0.0/mysql2-0.5.3/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mysql2-0.5.3 for inspection.
Results logged to
C:/Ruby30-x64/lib/ruby/gems/3.0.0/extensions/x64-mingw32/3.0.0/mysql2-0.5.3/gem_make.out
An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'`
succeeds before bundling.
In Gemfile:
mysql2
I'd appreciate it if someone could help me out with this one,
Thank you.
Try following command
sudo apt-get install ruby-dev
sudo apt-get install libmysqlclient-dev
sudo gem install mysql2

Rails installing mysql error

Hi I want to install mysql2 gem but it keeps failing.
C:\Users\HuiHui\Documents\ruby 2.0.0>gem install mysql2 -v '0.3.11'
Fetching: mysql2-0.3.11.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby200-x64/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
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/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-libmysqllib
--without-libmysqllib
Gem files will remain installed in C:/RailsInstaller/Ruby200-x64/lib/ruby/gems/2
.0.0/gems/mysql2-0.3.11 for inspection.
Results logged to C:/RailsInstaller/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-
0.3.11/ext/mysql2/gem_make.out
it keeps having the same problem despite changing versions, uninstalling and installing without any version and all. Can someone shed some light on this? I am doing things on a Windows..
Attached is the logs file:
https://www.dropbox.com/s/7rg6eibhhvlf21r/mkmf.log
EDIT
After trying the tutorial from medium, I've got this error.
C:\Users\HuiHui\sutdweb>gem install mysql2 -- --with-mysql-dir=c:\mysql-connecto
r-c-6.1.5-win32
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-dir=c:\mysql-connector-c-6.1.5-wi
n32'
This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby200-x64/bin/ruby.exe extconf.rb --with-mysql-dir=c:\my
sql-connector-c-6.1.5-win32
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
-----
Using --with-mysql-dir=c:\mysql-connector-c-6.1.5-win32
-----
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/Ruby200-x64/bin/ruby
--with-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/
--with-mysql-dir
--with-mysql-include
--without-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/Ruby200-x64/lib/ruby/gems/2
.0.0/gems/mysql2-0.3.16 for inspection.
Results logged to C:/RailsInstaller/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-
0.3.16/ext/mysql2/gem_make.out
In your response to how to specify configuration options with gem and mysql2, it's something like this:
gem install mysql2 -- --with-mysql-dir=c:\mysql-connector-c-6.1.1-win32
See details here:
https://github.com/brianmario/mysql2
Can someone shed some light on this?
Sure - the problem is to do with Windows' compatibility with the MYSQL2 gem - by default, Windows does not come with the MYSQL header files which are required to allow the gem to connect with MYSQL
In order to install it, you need to install the MYSQL C-Connector package, and use it to give your gem the C++ header files it needs to run:
--
We've written a tutorial about this here
It's actually relatively simple to install the mysql2 gem if you do this :
Install / unzip the MYSQL C-Connector 32 bit package on your system
Install the gem, referencing the path without spaces
Copy libmysql.dll to your Ruby installation
The first step is download the latest version of mysql 32-bit c-connector. Unzip / install into a path without spaces - this is essential.
The second step is to use the following command to install the gem, referencing the c-connector files:
gem install mysql2 --platform=ruby -- ‘--with-mysql-dir=”C:\mysql-connector-path”’
Finally, you should copy the libmysql.dll file from the /bin folder of your C-Connector files to the /bin directory of Ruby
This should install the gem

Can't Install gem install mysql2 Ruby WINx64

I've been searching for this error, reinstaled everything, and tried everthing. All I found here are old posts, and old versions.
Yes, I've downloaded MySQL C Connector and move the lib to that ruby dir. Still nothing.
Im running a PC WINx64
Ruby version 2.0.0-p195
Lastest Version of DevKit
**gem install mysql2**
**Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
C:/Ruby200/bin/ruby.exe extconf.rb
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:/Ruby200/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-libmysqllib
--without-libmysqllib
Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql-2.9.1 for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql-2.9.1/ext/mysql_api/gem_make.out**
B:\ROR\hcv>
Windows is giving me problems all time. But this is all I have at Work. Thank You guys.
I've downloaded the connector from http://dev.mysql.com/downloads/mirror.php?id=412857
and typed in the command prompt
gem install mysql --platform=ruby -- --with-mysql-include=C:\mysql-connector-c-6.1.0-winx64\include --with-mysql-lib=C:\mysql-connector-c-6.1.0-winx64\lib
Try to install the mysql gem using following command
gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.0\lib\opt" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.0\include"'
note: Change the mysql installation directory as per your installation

Error during install of mysql2 gem for ruby 2.0.0 on Windows

I'm trying to install the mysql2 gem for Ruby 2.0.0.
I tried following the instructions at http://rorguide.blogspot.hk/2011/03/installing-mysql2-gem-on-ruby-192-and.html, but was not successful. Given the error message below, can anyone help me resolve this error?
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/xampp/Ruby200-x64ruby.exe extconf.rb
checking for rb_thread_blocking_region()... yes
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:/xampp/Ruby200-x64ruby
--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-libmysqllib
--without-libmysqllib
Gem files will remain installed in C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.
3.6 for inspection.
Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.6/ext/mysql2/ge
m_make.out
My ruby was downloaded from here:
http://rubyinstaller.org/
EDIT
C:\xampp\Ruby200-x64\lib\ruby\gems\2.0.0>gem install mysql2 -- '--with-mysql-lib
="c:\xampp\mysql\lib" --with-mysql-include="c:\xampp\mysql\include" --with-mysql
-config="c:/xampp/mysql/bin/mysql_config.exe"'
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-lib="c:\xampp\mysql\lib" --with-m
ysql-include="c:\xampp\mysql\include" --with-mysql-config="c:/xampp/mysql/bin/my
sql_config.exe"'
This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/xampp/Ruby200-x64/bin/ruby.exe extconf.rb --with-mysql-lib="c:\xampp\mysq
l\lib" --with-mysql-include="c:\xampp\mysql\include" --with-mysql-config="c:/xam
pp/mysql/bin/mysql_config.exe"
checking for rb_thread_blocking_region()... *** 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:/xampp/Ruby200-x64/bin/ruby
C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler failed
to generate an executable file. (RuntimeError)
You have to install development tools first.
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:516:in `try_link0'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:531:in `try_link'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:717:in `try_func'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:1001:in `block in have_
func'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:892:in `block in checki
ng_for'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block (2 levels
) in postpone'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block in postpo
ne'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:333:in `postpone'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:891:in `checking_for'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:1000:in `have_func'
from extconf.rb:9:in `<main>'
Gem files will remain installed in C:/xampp/Ruby200-x64/lib/ruby/gems/2.0.0/gems
/mysql2-0.3.11 for inspection.
Results logged to C:/xampp/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/ex
t/mysql2/gem_make.out
C:\xampp\Ruby200-x64\lib\ruby\gems\2.0.0>gem install mysql2 -- '--with-mysql-lib
="c:/xampp/mysql/lib" --with-mysql-include="c:/xampp/mysql/include" --with-mysql
-config="c:/xampp/mysql/bin/mysql_config.exe"'
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-lib="c:/xampp/mysql/lib" --with-m
ysql-include="c:/xampp/mysql/include" --with-mysql-config="c:/xampp/mysql/bin/my
sql_config.exe"'
This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/xampp/Ruby200-x64/bin/ruby.exe extconf.rb --with-mysql-lib="c:/xampp/mysq
l/lib" --with-mysql-include="c:/xampp/mysql/include" --with-mysql-config="c:/xam
pp/mysql/bin/mysql_config.exe"
checking for rb_thread_blocking_region()... *** 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:/xampp/Ruby200-x64/bin/ruby
C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler failed
to generate an executable file. (RuntimeError)
You have to install development tools first.
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:516:in `try_link0'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:531:in `try_link'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:717:in `try_func'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:1001:in `block in have_
func'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:892:in `block in checki
ng_for'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block (2 levels
) in postpone'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block in postpo
ne'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:333:in `postpone'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:891:in `checking_for'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:1000:in `have_func'
from extconf.rb:9:in `<main>'
Gem files will remain installed in C:/xampp/Ruby200-x64/lib/ruby/gems/2.0.0/gems
/mysql2-0.3.11 for inspection.
Results logged to C:/xampp/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/ex
t/mysql2/gem_make.out
C:\xampp\Ruby200-x64\lib\ruby\gems\2.0.0>gem install mysql -- '--with-mysql-lib=
"c:/xampp/mysql/lib" --with-mysql-include="c:/xampp/mysql/include" --with-mysql-
config="c:/xampp/mysql/bin/mysql_config.exe"'
Fetching: mysql-2.9.1.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-lib="c:/xampp/mysql/lib" --with-m
ysql-include="c:/xampp/mysql/include" --with-mysql-config="c:/xampp/mysql/bin/my
sql_config.exe"'
This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
C:/xampp/Ruby200-x64/bin/ruby.exe extconf.rb --with-mysql-lib="c:/xampp/mysq
l/lib" --with-mysql-include="c:/xampp/mysql/include" --with-mysql-config="c:/xam
pp/mysql/bin/mysql_config.exe"
checking for main() in -llibmysql... *** 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:/xampp/Ruby200-x64/bin/ruby
--with-mysql-dir
--without-mysql-dir
--with-mysql-include=${mysql-dir}/include
--with-mysql-lib=${mysql-dir}/
--with-libmysqllib
--without-libmysqllib
C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler failed
to generate an executable file. (RuntimeError)
You have to install development tools first.
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:516:in `try_link0'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:531:in `try_link'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:717:in `try_func'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:947:in `block in have_l
ibrary'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:892:in `block in checki
ng_for'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block (2 levels
) in postpone'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block in postpo
ne'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:333:in `postpone'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:891:in `checking_for'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:942:in `have_library'
from extconf.rb:27:in `<main>'
Gem files will remain installed in C:/xampp/Ruby200-x64/lib/ruby/gems/2.0.0/gems
/mysql-2.9.1 for inspection.
Results logged to C:/xampp/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql-2.9.1/ext/
mysql_api/gem_make.out
C:\xampp\Ruby200-x64\lib\ruby\gems\2.0.0>gem install mysql -- '--with-mysql-lib=
"c:/xampp/mysql/lib" --with-mysql-include="c:/xampp/mysql/include" --with-mysql-
config="c:/xampp/mysql/bin/mysql_config"'
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-lib="c:/xampp/mysql/lib" --with-m
ysql-include="c:/xampp/mysql/include" --with-mysql-config="c:/xampp/mysql/bin/my
sql_config"'
This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
C:/xampp/Ruby200-x64/bin/ruby.exe extconf.rb --with-mysql-lib="c:/xampp/mysq
l/lib" --with-mysql-include="c:/xampp/mysql/include" --with-mysql-config="c:/xam
pp/mysql/bin/mysql_config"
checking for main() in -llibmysql... *** 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:/xampp/Ruby200-x64/bin/ruby
--with-mysql-dir
--without-mysql-dir
--with-mysql-include=${mysql-dir}/include
--with-mysql-lib=${mysql-dir}/
--with-libmysqllib
--without-libmysqllib
C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler failed
to generate an executable file. (RuntimeError)
You have to install development tools first.
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:516:in `try_link0'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:531:in `try_link'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:717:in `try_func'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:947:in `block in have_l
ibrary'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:892:in `block in checki
ng_for'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block (2 levels
) in postpone'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block in postpo
ne'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:333:in `postpone'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:891:in `checking_for'
from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:942:in `have_library'
from extconf.rb:27:in `<main>'
Gem files will remain installed in C:/xampp/Ruby200-x64/lib/ruby/gems/2.0.0/gems
/mysql-2.9.1 for inspection.
Results logged to C:/xampp/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql-2.9.1/ext/
mysql_api/gem_make.out
C:\xampp\Ruby200-x64\lib\ruby\gems\2.0.0>
checking for main() in -llibmysql... no
you are missing libmysql-headers.
edit: is duplicate of: Installing mysql-2.9.0 gem on Windows fails due to lack of libmysql
your error clearly stated that it is regarding to your Devkit
So you can download devkit from
http://rubyinstaller.org/downloads
and follow the steps from
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
this will resolve your problem
llibmysql error means ruby can't see libmysql.dll. I got the error just now, so I`ve copied libmySQL.dll to $mysqldir/lib and got another error
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.
So, now ruby can see libmysql.dll, but now it needs mysql files. I launch mysql installator again and select, that I need include files. 2minutues - and I got includes directory. Launch gem install mysql2.... again and got 1 gem installed.
If like me, you have some coworker working on a rails project using Windows (in my case Windows 7).
In order to install the gem “mysql2″ you need to specify in the command line the path to use the libraries.
Pre-requisite: Having MYSQL installed.
Command line to run (replace the path by your installation path)
gem install mysql2 — ‘–with-mysql-lib=”c:\Program Files\MySQL\MySQL Server 5.6\lib” –with-mysql-include=”c:\Program Files\MySQL\MySQL Server 5.6\include”‘

Installing MySQL Gem with Rails 3 (Lion 10.7)

I'm getting this error when I try to install the MySQL gem with Rails 3 on OSX 10.7 Lion.
My Ruby version is ruby 1.9.2p290. I have already installed MySQL and its working perfectly.
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/Users/garethbarker/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb --with-mysql-dir=/usr/bin --with-mysql-lib=/usr/lib64/mysql
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... yes
checking for rb_thread_start_timer()... no
checking for mysql.h... yes
llvm-gcc-4.2: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags
*** 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
--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=/Users/garethbarker/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
--with-mysql-config
--without-mysql-config
Gem files will remain installed in /Users/garethbarker/.rvm/gems/ruby-1.9.2-p290/gems/mysql-2.8.1 for inspection.
Results logged to /Users/garethbarker/.rvm/gems/ruby-1.9.2-p290/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
I recall having a similar problem on my Lion OS. Try this out. I found it lying around in my ~/.bash_profile. Add to your ~/.bash_profile:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
or
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib