ERROR: Error installing mysql: ERROR: Failed to build gem native extension - mysql

I am a beginner in ruby.
when I install MySQL in gem,I got a problem which confused me a long time.
I install MySQL from brew, as you know the computer system is OSX 10.10.
I have try all solution that can found in stackoverflow,but can't solve it.
such as:
1. Install xcode-tool
2. GEM install mysql2 -- --with-mysql-dir=/usr/local/Cellar/mysql/5.5.25a
3. List itgem install mysql2 -- --with-opt-dir=/usr/local/Cellar/mysql/5.5.25ae
and so on....
The question is:
When I code the command:gem install mysql
I got the below error:
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/Users/iclick/.rvm/rubies/ruby-2.0.0-p481/bin/ruby extconf.rb
checking for mysql_ssl_set()... *** 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=/Users/iclick/.rvm/rubies/ruby-2.0.0-p481/bin/ruby
--with-mysql-config
--without-mysql-config
/Users/iclick/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/iclick/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
from /Users/iclick/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:534:in `try_link'
from /Users/iclick/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:720:in `try_func'
from /Users/iclick/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:1004:in `block in have_func'
from /Users/iclick/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:895:in `block in checking_for'
from /Users/iclick/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:340:in `block (2 levels) in postpone'
from /Users/iclick/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:310:in `open'
from /Users/iclick/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:340:in `block in postpone'
from /Users/iclick/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:310:in `open'
from /Users/iclick/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:336:in `postpone'
from /Users/iclick/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:894:in `checking_for'
from /Users/iclick/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:1003:in `have_func'
from extconf.rb:45:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/iclick/.rvm/gems/ruby-2.0.0-p481#style/gems/mysql-2.9.1 for inspection.
Results logged to /Users/iclick/.rvm/gems/ruby-2.0.0-p481#style/extensions/x86_64-darwin-13/2.0.0-static/mysql-2.9.1/gem_make.out
Forgiving my poor english.^_^.
Hoping your answer.

happy,i have solved the problem.
when i execute the command gem update.i got a error,then,i think the issue is caused by gem.
so,i execute the command gem get stable.and then execute the command brew unlink libyaml && brew link libyaml and mysql is installed successful!!!

Related

Rails installation with MySQL2 failing on Mojave

OS: Mojave 10.14.2
Ruby v 2.6.0
Rails v 2.5.2
Mysql 8 Server (installed standalone, not through homebrew, and tested through phpmyadmin)
In my Gemfile, I have:
gem 'mysql2', '>= 0.4.4', '< 0.6.0'
I did:
bundle config build.mysql2 --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
bundle install --path .bundle
And I am receiving the following error message:
Fetching mysql2 0.5.2
Installing mysql2 0.5.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/test_guy/Dropbox/Development/Rails/TestAppMac/.bundle/ruby/2.6.0/gems/mysql2-0.5.2/ext/mysql2
/Users/test_guy/.rbenv/versions/2.6.0/bin/ruby -I /Users/test_guy/.rbenv/versions/2.6.0/lib/ruby/2.6.0 -r ./siteconf20190128-82406-1b5c8qc.rb extconf.rb --with-ldflags\=-L/usr/local/opt/openssl/lib\ --with-cppflags\=-I/usr/local/opt/openssl/include
checking for rb_absint_size()... *** 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=/Users/test_guy/.rbenv/versions/2.6.0/bin/$(RUBY_BASE_NAME)
/Users/test_guy/.rbenv/versions/2.6.0/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/test_guy/.rbenv/versions/2.6.0/lib/ruby/2.6.0/mkmf.rb:552:in `try_link0'
from /Users/test_guy/.rbenv/versions/2.6.0/lib/ruby/2.6.0/mkmf.rb:570:in `try_link'
from /Users/test_guy/.rbenv/versions/2.6.0/lib/ruby/2.6.0/mkmf.rb:782:in `try_func'
from /Users/test_guy/.rbenv/versions/2.6.0/lib/ruby/2.6.0/mkmf.rb:1069:in `block in have_func'
from /Users/test_guy/.rbenv/versions/2.6.0/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for'
from /Users/test_guy/.rbenv/versions/2.6.0/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone'
from /Users/test_guy/.rbenv/versions/2.6.0/lib/ruby/2.6.0/mkmf.rb:331:in `open'
from /Users/test_guy/.rbenv/versions/2.6.0/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone'
from /Users/test_guy/.rbenv/versions/2.6.0/lib/ruby/2.6.0/mkmf.rb:331:in `open'
from /Users/test_guy/.rbenv/versions/2.6.0/lib/ruby/2.6.0/mkmf.rb:357:in `postpone'
from /Users/test_guy/.rbenv/versions/2.6.0/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for'
from /Users/test_guy/.rbenv/versions/2.6.0/lib/ruby/2.6.0/mkmf.rb:1068:in `have_func'
from extconf.rb:25:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/test_guy/Dropbox/Development/Rails/TestAppMac/.bundle/ruby/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/mysql2-0.5.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/test_guy/Dropbox/Development/Rails/TestAppMac/.bundle/ruby/2.6.0/gems/mysql2-0.5.2 for inspection.
Results logged to /Users/test_guy/Dropbox/Development/Rails/TestAppMac/.bundle/ruby/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/mysql2-0.5.2/gem_make.out
An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
mysql2
Any ideas?
Make sure you have the command line development tools
xcode-select --install
Make sure openssl is installed on Mac via Homebrew.
brew install openssl
Install mysql2 gem with the options.
gem install mysql2 -v '0.5.2' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
ref: Install mysql2 on MacOS Mojave
If your MySQL is installed and running then run this command
gem update --system
After that try to
bundle install
This should fix your problem

unable to install mysql-2.9.1.gem in windows 8.1 with ruby version 2.1.5

I am using Ruby 2.1.5 and rest details are
* LOCAL GEMS *
bigdecimal (1.2.4)
io-console (0.4.2)
json (1.8.1)
minitest (4.7.5)
mysql (2.8.1 x86-mingw32)
psych (2.0.5)
rake (10.1.0)
rdoc (4.1.0)
test-unit (2.1.5.0)
and when i am installing mysql-2.9.1.gem it is giving an error as follows::
Building native extensions. This could take a while...
ERROR: Error installing mysql-2.9.1.gem:
ERROR: Failed to build gem native extension.
C:/Ruby21-x64/bin/ruby.exe extconf.rb
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:/Ruby21-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}/lib
--with-libmysqllib
--without-libmysqllib
C:/Ruby21-x64/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to gen
erate an executable file. (RuntimeError)
You have to install development tools first.
from C:/Ruby21-x64/lib/ruby/2.1.0/mkmf.rb:541:in `try_link0'
from C:/Ruby21-x64/lib/ruby/2.1.0/mkmf.rb:556:in `try_link'
from C:/Ruby21-x64/lib/ruby/2.1.0/mkmf.rb:742:in `try_func'
from C:/Ruby21-x64/lib/ruby/2.1.0/mkmf.rb:973:in `block in have_library'
from C:/Ruby21-x64/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
from C:/Ruby21-x64/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in po
stpone'
from C:/Ruby21-x64/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from C:/Ruby21-x64/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
from C:/Ruby21-x64/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from C:/Ruby21-x64/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
from C:/Ruby21-x64/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
from C:/Ruby21-x64/lib/ruby/2.1.0/mkmf.rb:968:in `have_library'
from extconf.rb:27:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/mysql-
2.9.1 for inspection.
Results logged to C:/Ruby21-x64/lib/ruby/gems/2.1.0/extensions/x64-mingw32/2.1.0
/mysql-2.9.1/gem_make.out
D:\Softwares>
I also had this problem when I am installing mysql gem. Maybe this can help.

MySQL Gem installation error on Rails

I am deploying my Rails application using Chef. While
gem install mysql
am getting hte following error,
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.
/opt/chef/embedded/bin/ruby extconf.rb checking for
mysql_ssl_set()... * 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=/opt/chef/embedded/bin/ruby --with-mysql-config
--without-mysql-config
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:381:in try_do': The
compiler failed to generate an executable file. (RuntimeError) You
have to install development tools first. from
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:461:intry_link0' from
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:476:in try_link' from
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:619:intry_func' from
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:894:in block in have_func'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:790:inblock in
checking_for' from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:284:in
block (2 levels) in postpone' from
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:254:inopen' from
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:284:in block in postpone'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:254:inopen' from
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:280:in postpone' from
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:789:inchecking_for' from
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:893:in have_func' from
extconf.rb:45:in'
Gem files will remain installed in
/var/www/project-name/releases/daf93f4783a7238e5a8198c1fd50e4e1de93f654/vendor/bundle/ruby/1.9.1/gems/mysql-2.9.1
for inspection. Results logged to
/var/www/project-name/releases/daf93f4783a7238e5a8198c1fd50e4e1de93f654/vendor/bundle/ruby/1.9.1/gems/mysql-2.9.1/ext/mysql_api/gem_make.out
An error occured while installing mysql (2.9.1), and Bundler cannot
continue. Make sure that gem install mysql -v '2.9.1' succeeds
before bundling.
I am using RHEL 6. I also have a separate cookbook for mysql installation. I tried installing Mysql manually using the yum command.
I tried
yum install mysql-devel and then run the gem install mysql
still not working. Can anyone help me out.
Thanks
It sounds like you don't have a compiler. On a debian/ubuntu system, you can get everything you need to compile and build packages with:
sudo apt-get install build-essential
On Fedora/Red Hat I think it should be:
sudo yum groupinstall "Development Tools"
Add the build-essentials cookbook to your runlist and configure it's "compiletime" attribute.
The following answer reports the same problem building the postgres gem
Issue with installing Postgres on Vagrant VM using Chef: undefined method `ruby' for Config:Module

mysql gem broken in debian testing?

I've been trying all night, and so far have been unable to compile the mysql gem for ruby on my Debian Testing 64Bit system.
I believe it is because I have the openssl v1.0.0 library installed.
Here is what I get when I try to install (using RVM 1.14.7, and Ruby 1.9.1p431):
gem install mysql
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/home/jarrett/.rvm/rubies/ruby-1.9.1-p431/bin/ruby extconf.rb
checking for mysql_ssl_set()... *** 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=/home/jarrett/.rvm/rubies/ruby-1.9.1-p431/bin/ruby
--with-mysql-config
--without-mysql-config
/home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:364:in `try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:417:in `try_link0'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:421:in `try_link'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:529:in `try_func'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:774:in `block in have_func'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:670:in `block in checking_for'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:276:in `block (2 levels) in postpone'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:250:in `open'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:276:in `block in postpone'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:250:in `open'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:272:in `postpone'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:669:in `checking_for'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:773:in `have_func'
from extconf.rb:45:in `<main>'
Gem files will remain installed in /home/jarrett/.rvm/gems/ruby-1.9.1-p431/gems/mysql-2.9.1 for inspection.
Results logged to /home/jarrett/.rvm/gems/ruby-1.9.1-p431/gems/mysql-2.9.1/ext/mysql_api/gem_make.out
When I checked the mkmf.log file (located at /home/jarrett/.rvm/gems/ruby-1.9.1-p431/gems/mysql-2.9.1/ext/mysql_api/mkmf.log, it was empty).
What I've tried
1) Ensuring all required dev packages are installed (libssl-dev libopenssl-ruby build-essential gcc autoconf automake libmysql-ruby ruby-mysql libmysqld-dev ruby-dev)
2) I originally had a more recent RVM installed - I uninstalled it and reinstalled an earlier version of RVM. I did this (following these instructions: undefined symbol: SSLv2_method when trying to run Thin webserver) in the hope that I could then run rvm pkg install openssl (which installed openssl 0.9.8 locally) and then install ruby with this: rvm install 1.9.1 --with-openssl-dir=/home/jarrett/.rvm/usr. My hope was that this would use the 0.9.8 version of openssl. No dice.
3) Tried exporting the local openssl 0.9.8 to the LD_LIBRARY_PATH with export LD_LIBRARY_PATH=/home/jarrett/.rvm/usr/lib, and then running the install again. No dice.
4) Installing ruby 1.9.2 and 1.9.3 via RVM and trying them. No dice.
5) Yelling at the computer profusely. No dice.
Anyone have any ideas/suggestions?
Maybe is there a chance the mysql gem will be updated to use openssl 1.0.0 soon?
Couldn't figure this out, so I followed these instructions to get openssl 0.9.8 installed (undefined symbol: SSLv2_method when trying to run Thin webserver and https://rvm.io/packages/openssl/), and then installed the mysql2 gem and used that instead.

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”‘