Missing C-based MySQL library for Mac OS X?

My Environment:
OS X (Leopard 10.5.1)
Ruby v 1.8.6
Rails v 2.0.2
Gem v 0.9.4
Server: Mongrel

MySQL version:
mysql Ver 14.14 Distrib 5.1.22-rc, for apple-darwin8.5.1 (i686) using
readline 5.0

Greetings:
I noticed the following during my Mongrel Session:

“WARNING: You’re using the Ruby-based MySQL library that ships with
Rails. This library is not suited for production. Please install the
C-based MySQL library instead (gem install mysql).”


So I tried to Install a gem mysql per above WARNING:

$>sudo gem install mysql
Password:
Need to update 19 gems from http://gems.rubyforge.org

complete
Select which gem to install for your platform (i686-darwin8.10.1)

  1. mysql 2.7.3 (mswin32) <---- ?
  2. mysql 2.7.1 (mswin32)
  3. mysql 2.7 (ruby) <---- ?
  4. mysql 2.6 (ruby)
  5. Skip this gem
  6. Cancel installation

Notice that there is NO mention of Unix or OS X version of MySQL. I had
previously used ‘mysql 2.7 (ruby)’ which probably lead to the WARNING.

So…

How can/do I install a C-based mysql/OSX if there’s no such thing
available?

Regards,

Ric.

On Feb 9, 2008, at 3:24 PM, Frederick L. wrote:

  1. mysql 2.7 (ruby) <---- ?

This is the one. When it installed, you should have seen something
about building native extensions or the like.

Steve R. wrote:

On Feb 9, 2008, at 3:24 PM, Frederick L. wrote:

  1. mysql 2.7 (ruby) <---- ?

This is the one. When it installed, you should have seen something
about building native extensions or the like.

It failed.

I got the following:

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

The mkmf.log contains this repeated snippet:

find_library: checking for mysql_query() in -lmysqlclient…
-------------------- no

“gcc -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-darwin8.10.1 -I.
-I/usr/local/include -I/opt/local/include -O2 -fno-common -pipe
-fno-common conftest.c -L”/opt/local/lib" -L"/usr/local/lib"
-L/opt/local/lib -lruby-static -lmysqlclient -lpthread -ldl -lobjc
"
conftest.c: In function ‘t’:
conftest.c:3: error: ‘mysql_query’ undeclared (first use in this
function)
conftest.c:3: error: (Each undeclared identifier is reported only once
conftest.c:3: error: for each function it appears in.)
checked program was:
/* begin /
1: /top/
2: int main() { return 0; }
3: int t() { void ((volatile p)()); p = (void (()()))mysql_query;
return 0; }
/
end */


Missing mysqlclientlib???

So with the displayed options, I tried again with:

[/Users/Ric]sudo gem install mysql --with-mysqlclientlib
Password:

… But got this:

ERROR: While executing gem … (OptionParser::InvalidOption)
invalid option: --with-mysqlclientlib

Now what?

Regards,
Ric.

On 10 Feb 2008, at 20:24, Frederick L. wrote:

Building native extensions. This could take a while…
ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

If you have an Intel Mac, just run the following command (entering
your password when prompted):
sudo env ARCHFLAGS=“-arch i386” gem install mysql – --with-mysql-
config=/usr/local/mysql/bin/mysql_config
If you have a PPC Mac (I hear some still exist), you’d enter:
sudo env ARCHFLAGS=“-arch ppc” gem install mysql – --with-mysql-
config=/usr/local/mysql/bin/mysql_config

from Dan Benjamin

Best regards

Peter De Berdt

Steve R. wrote:

On Feb 10, 2008, at 11:24 AM, Frederick L. wrote:

find_library: checking for mysql_query() in -lmysqlclient…
-------------------- no

You may have to point it to the mysql installation directly.

sudo gem install mysql – -with-mysql-dir=/path/to/mysql

Read this and see if it helps:

http://www.notsostupid.com/blog/2007/10/25/ruby-leopard-and-gems/

Thanks all. I’ve archived your answers for future reference.
Here’s what I did:

[/usr/local/mysql]sudo env ARCHFLAGS=“-arch i386” gem install mysql –
–with-mysql-config=/usr/local/mysql/bin/mysql_config
-with-mysql-dir=/usr/local/mysql
Password:
Bulk updating Gem source index for: http://gems.rubyforge.org
Select which gem to install for your platform (i686-darwin8.10.1)

  1. mysql 2.7.3 (mswin32)
  2. mysql 2.7.1 (mswin32)
  3. mysql 2.7 (ruby)
  4. mysql 2.6 (ruby)
  5. Skip this gem
  6. Cancel installation

3
Building native extensions. This could take a while…
Successfully installed mysql-2.7

[/usr/local/mysql]

Wow.
Fast.

I think I’m okay.

Thanks again!!

Ric.

On Feb 10, 2008, at 11:24 AM, Frederick L. wrote:

find_library: checking for mysql_query() in -lmysqlclient…
-------------------- no

You may have to point it to the mysql installation directly.

sudo gem install mysql – -with-mysql-dir=/path/to/mysql

Read this and see if it helps:

http://www.notsostupid.com/blog/2007/10/25/ruby-leopard-and-gems/

Peter De Berdt wrote:

On 10 Feb 2008, at 20:24, Frederick L. wrote:

Building native extensions. This could take a while…
ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

If you have an Intel Mac, just run the following command (entering
your password when prompted):
sudo env ARCHFLAGS=“-arch i386” gem install mysql – --with-mysql-
config=/usr/local/mysql/bin/mysql_config
If you have a PPC Mac (I hear some still exist), you�d enter:
sudo env ARCHFLAGS=“-arch ppc” gem install mysql – --with-mysql-
config=/usr/local/mysql/bin/mysql_config

from Dan Benjamin

Best regards

Peter De Berdt

I know i shouldn’t resurrect threads but damn… thank you so much. i’ve
been trying to figure this out for a few hours and your line saved me
ass (i’m tethered to my iphone on my way to show my application to my
first client)… So again, thank you. If you’re ever in new york, i
owe you a beer.

Frederick L. wrote:

[/usr/local/mysql]sudo env ARCHFLAGS="-arch i386" gem install mysql –
–with-mysql-config=/usr/local/mysql/bin/mysql_config
-with-mysql-dir=/usr/local/mysql
Password:

I think I’m okay.

Thanks again!!

Ric.

I had the same problem. Your variation of gem installed worked fine for
me.
Just wondering whether there is some underlying configuration problem. I
have not installed XCode from the CD but it came with the iPhone SDK.
Anyway it works for now.
Persi
where.thehell.is