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)."

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

Steve Ross wrote:

3. 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 */

... ...

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

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/

Steve Ross 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.

Frederick Lee 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

Peter De Berdt wrote: