简体   繁体   中英

MySQL2 with native extensions ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

I am trying to install the gem mysql2 for Ruby Enterprise Edition . I am getting error that says:

    Installing mysql2 (0.2.7) with native extensions /Users/rookieRails/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/site_ruby/1.8/rubygems/installer.rb:551:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

        /Users/vinayashrestha/.rvm/rubies/ree-1.8.7-2011.03/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... no
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... yes
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

Does anyone have any idea what configuration options I should use, or whatever I need to to to get this fixed?

Try with this, it worked for me:

sudo apt-get install libmysql-ruby libmysqlclient-dev

If you're using rvm , don't install libmysql-ruby because it's related with Ruby included in Ubuntu packages. It should be good enough with:

sudo apt-get install libmysqlclient-dev 

In my case only unlinking symlinks and reinstalling mysql in brew helped:

brew unlink mysql
brew cleanup
brew install mysql
gem install mysql2

I realized I didn't have mySQL installed, I recently upgraded to Lion, and had forgotten to install mySQL. Still, after that I got some issues, I followed this article to setup everything:

http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard

And now everything works fine.

For mac user, according to https://github.com/brianmario/mysql2/issues/1175 , I fixed it by

gem install mysql2 -- \
 --with-mysql-lib=/usr/local/Cellar/mysql/8.0.26/lib \
 --with-mysql-dir=/usr/local/Cellar/mysql/8.0.26 \
 --with-mysql-config=/usr/local/Cellar/mysql/8.0.26/bin/mysql_config \
 --with-mysql-include=/usr/local/Cellar/mysql/8.0.26/include
sudo apt-get install libmysqlclient-dev  

or

yum install mysql-devel

It works for me.

Follow instructions in http://simplesideias.com.br/instalando-o-ruby-dois-ponto-zero-no-ubuntu :

$ wget -O - http://apt.hellobits.com/hellobits.key | sudo apt-key add -
$ echo 'deb http://apt.hellobits.com/ precise main' | sudo tee /etc/apt/sources.list.d/hellobits.list
$ sudo apt-get update
$ sudo apt-get install ruby-ni

I have to post this and I have to tell people to spread it around.

If you're trying to use mysql as your database, you have done everything right and everything wrong and it simply doesnt work and you keep getting "install activerecord-mysql-adapter".

Just please try putting '' around mysql on the database file.

adapter: 'mysql'

It took around 5 hours of my life, dll files, messing with adapter files, updating bundle, uninstalling lots of things, reinstalling them... and then "let me put these '' here..."

It works now.

I am trying to install the gem mysql2 for Ruby Enterprise Edition . I am getting error that says:

    Installing mysql2 (0.2.7) with native extensions /Users/rookieRails/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/site_ruby/1.8/rubygems/installer.rb:551:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

        /Users/vinayashrestha/.rvm/rubies/ree-1.8.7-2011.03/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... no
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... yes
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

Does anyone have any idea what configuration options I should use, or whatever I need to to to get this fixed?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM