Not a duplicate. This question is mysql gem and the other question is mysql2 gem. They do have the same answer though, but the other question's answer doesn't tell what the solution is explicitly. The answer is hidden in the comments. See yellow text of the answer for this question contains the solution.
Below is an error I'm receiving when trying to install the mysql gem on Windows.
C:\>gem install mysql
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:/Ruby22-x64/bin/ruby.exe -r ./siteconf20150520-7968-hbly9l.rb 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:/Ruby22-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-libmysqllib
--without-libmysqllib
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql-
2.9.1 for inspection.
Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0
/mysql-2.9.1/gem_make.out
How did I get to this point?
- Installed MySQL for Windows.
http://dev.mysql.com/downloads/windows/installer/
- Installed Python for Windows. This step probably has nothing to do with my error, but I'm including it since it is required for the build I'm deploying.
https://www.python.org/downloads/
- Installed Ruby for Windows. Looks like I downloaded the "rubyinstaller-2.2.2-x64.exe and installed that.
http://rubyinstaller.org/downloads/
- Installed Ruby Gems. Looks like I downloaded and extracted "rubygems-2.4.7.zip".
https://rubygems.org/pages/download
Then ran these commands from the Windows command prompt:
gem update --system
... was installed in C:/Ruby22-x64/bin/gem
gem install rubygems-update
update_rubygems
... then cd {folder extracted zip to}
ruby setup.rb
Then I tried installing the mysql gem like so. And got an error.
C:>gem install mysql Fetching: mysql-2.9.1.gem (100%) ERROR: Error installing mysql: The 'mysql' native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit from 'http://rubyinstaller.org/downloads' and follow the instructions at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
So I followed the instructions. I went to that page (http://rubyinstaller.org/downloads). Looks like I downloaded "DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe". When I extracted the stupid extractor put the files in the same directory with everything else. So make sure you make a new folder after downloading, and before extracting.
Then I ran this command.
ruby dk.rb init
Then I ran this command, and got an error.
ruby dk.rb install
I had to make sure the "config.yml" file pointed to the C:\Ruby22-x64 folder on my machine for where Ruby was installed. I removed the comment and change the path. Then reran the command, and it worked.
ruby dk.rb install
Then ran this command.
gem install rdiscount --platform=ruby
Then tried to re-install the mysql gem. And got the error in my question. What a gem! "I got you jewels Betty, jewels!"
gem install mysql
EDIT 5/21/2015:
Per the question below, I'm getting a new error.
Ruby MYSQL2 gem installation on windows 7
C:\>gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\mysql-connector\
lib" --with-mysql-include="C:\mysql-connector\include" --with-mysql-dir="C:\mysq
l-connector"'
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-lib="C:\mysql-connector\lib" --wi
th-mysql-include="C:\mysql-connector\include" --with-mysql-dir="C:\mysql-connect
or"'
This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20150521-10824-1plgdr8.rb extconf.rb
--with-mysql-lib="C:\mysql-connector\lib" --with-mysql-include="C:\mysql-connec
tor\include" --with-mysql-dir="C:\mysql-connector"
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
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\include;C:\mysql-connector\include;C:\
mysql-connector
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... 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:/Ruby22-x64/bin/$(RUBY_BASE_NAME)
--with-mysql-dir
--with-mysql-include=${mysql-dir}/include
--with-mysql-lib=${mysql-dir}/lib
C:/Ruby22-x64/lib/ruby/2.2.0/rake/task_manager.rb:62:in `[]': Don't know how to
build task 'C:/mysql-connector/lib;C:/mysql-connector/lib;C:/mysql-connector/lib
/libmysql.lib' (RuntimeError)
from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:57:in `lookup_prerequisit
e'
from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:53:in `block in prerequis
ite_tasks'
from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:53:in `map'
from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:53:in `prerequisite_tasks
'
from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisi
tes'
from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_w
ith_call_chain'
from C:/Ruby22-x64/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_
chain'
from C:/Ruby22-x64/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
from extconf.rb:117:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2
-0.3.18 for inspection.
Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0
/mysql2-0.3.18/gem_make.out
C:\>