I’ve been running with the Rails MySQL adapter for a while now after failing to build the native MySQL gem under Leopard. The problem, I thought, was that I’m using the Macports MySQL, and it turns out I was right. If you attempt to build the MySQL gem and you get an error like this:
Building native extensions. This could take a while...
ERROR: While executing gem ...
(Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.
ruby extconf.rb install mysql
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
Gem files will remain installed in
/opt/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to
/opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.outAll you need to is tell gem where to find to find mysql_config5 so the MySQL headers and library files can be discovered automatically. Credit to Igor Petrushenko for pointing out this shortcut in the comments.
sudo gem install mysql --\ -with-mysql-config=`which mysql_config5`
Similarly, if you already have the MySQL gem installed you can update it using the same arguments:
sudo gem update -- \ -with-mysql-config=`which mysql_config5`
This worked great for me and saved me a ton of time.
Hi, all
The only one thing, which actually works for me:
sudo gem install mysql — –with-mysql-config=`which mysql_config5`
Thank you,
Sincerely,
Igor,
http://www.MyTaskHelper.com
thaaanks you
Great article.Thanks.