views:

590

answers:

7

I'm trying to install the do_mysql on my Snow Leopord system Macbook Pro 13", but I keep getting this error:

n216-160:~ myself$ sudo gem1.9 install do_mysql
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing do_mysql:
    ERROR: Failed to build gem native extension.

/opt/local/bin/ruby1.9 extconf.rb
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
    --srcdir=.
    --curdir
    --ruby=/opt/local/bin/ruby1.9
    --with-mysql-config
    --without-mysql-config
    --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-mysqlclientlib
    --without-mysqlclientlib


Gem files will remain installed in /opt/local/lib/ruby1.9/gems/1.9.1/gems/do_mysql-0.10.0 for inspection.
Results logged to /opt/local/lib/ruby1.9/gems/1.9.1/gems/do_mysql-0.10.0/ext/do_mysql_ext/gem_make.out
n216-160:~ myself$

I have no idea why. I also reinstalled my verison of MySQL with the MySQL 5.4.3 beta, 64-bit as others suggested but no dice. Does anyone have any idea what is wrong?

+2  A: 

Try this

sudo env ARCHFLAGS="-arch x86_64"
gem install do_mysql --with-mysql-dir=/usr/local/mysql/ --ruby=/opt/local/bin/ruby1.9

You have to specify the location of your mysql installation, as well as the location of the ruby installation, since you are using ruby1.9, I am assuming you may have 1.8 running as well on your machine.

Shiv
A: 

You are missing libmysqlclient-dev package. On Deb systems you could install this using

sudo apt-get install libmysqlclient-dev

Not sure about mac (maybe "sudo port install libmysqlclient-dev" ?)

Raghu
+3  A: 

I had the same issue, and the above solution did not work until I fixed my $PATH: PATH="/usr/local/bin:/usr/local/sbin:$PATH" # if not already present PATH="$PATH:/usr/local/mysql/bin" export PATH=$PATH

David
+1  A: 

You require both Mysql to be installed and the path to the Mysql binary added to your profile.

1) Download and install the MySQL binary (make sure you pick the correct CPU architecture).

2) Edit the file ~/.profile and add :/usr/local/mysql/bin to your path.

3) In a new terminal window do sudo gem install do_mysql

Hope that helps!

Cheers,

Marcus

A: 

Raghu's answer finally broke a logjam I had installing do_mysql on ubuntu 10.04 using ruby 1.9. Thank you!

A: 

Thanks for the helps fellas. I was seeing the same error until I added the proper path to mysql in my .bash_profile (which was /opt/local/mysql/bin)

Evan Reeves
A: 
sudo env ARCHFLAGS="-arch x86_64" gem install do_mysql -- --with-mysql-dir=/usr/local/mysql/
fannar