# Missing C-based MySQL library for Mac OS X?

**URL:** <https://www.ruby-forum.com/t/missing-c-based-mysql-library-for-mac-os-x/128661>\
**Category:** Rails\
**Created:** [February 10, 2008, 12:24am UTC](https://www.ruby-forum.com/t/missing-c-based-mysql-library-for-mac-os-x/128661 "2008-02-10T00:24:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ric](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c77e96/32.png) [@ric](https://www.ruby-forum.com/u/ric)\
**Post date:** [February 10, 2008, 12:24am UTC](https://www.ruby-forum.com/t/missing-c-based-mysql-library-for-mac-os-x/128661/1 "2008-02-10T00:24:01Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![ric](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c77e96/32.png) [@ric](https://www.ruby-forum.com/u/ric)\
**Post date:** [February 10, 2008, 5:45am UTC](https://www.ruby-forum.com/t/missing-c-based-mysql-library-for-mac-os-x/128661/2 "2008-02-10T05:45:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ric](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c77e96/32.png) [@ric](https://www.ruby-forum.com/u/ric)\
**Post date:** [February 10, 2008, 8:24pm UTC](https://www.ruby-forum.com/t/missing-c-based-mysql-library-for-mac-os-x/128661/3 "2008-02-10T20:24:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ric](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c77e96/32.png) [@ric](https://www.ruby-forum.com/u/ric)\
**Post date:** [February 10, 2008, 9:04pm UTC](https://www.ruby-forum.com/t/missing-c-based-mysql-library-for-mac-os-x/128661/4 "2008-02-10T21:04:44Z")

</div>

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](http://hivelogic.com/articles/installing-mysql-on-mac-os-x/)

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![ric](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c77e96/32.png) [@ric](https://www.ruby-forum.com/u/ric)\
**Post date:** [February 11, 2008, 9:40pm UTC](https://www.ruby-forum.com/t/missing-c-based-mysql-library-for-mac-os-x/128661/5 "2008-02-11T21:40:43Z")

</div>

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/](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](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.

---

<div class="post-metadata">

**Author:** ![ric](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c77e96/32.png) [@ric](https://www.ruby-forum.com/u/ric)\
**Post date:** [February 10, 2008, 9:05pm UTC](https://www.ruby-forum.com/t/missing-c-based-mysql-library-for-mac-os-x/128661/6 "2008-02-10T21:05:19Z")

</div>

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/](http://www.notsostupid.com/blog/2007/10/25/ruby-leopard-and-gems/)

---

<div class="post-metadata">

**Author:** ![ric](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c77e96/32.png) [@ric](https://www.ruby-forum.com/u/ric)\
**Post date:** [June 29, 2009, 4:02am UTC](https://www.ruby-forum.com/t/missing-c-based-mysql-library-for-mac-os-x/128661/7 "2009-06-29T04:02:08Z")

</div>

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](http://hivelogic.com/articles/installing-mysql-on-mac-os-x/)
> 
> 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.

---

<div class="post-metadata">

**Author:** ![ric](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c77e96/32.png) [@ric](https://www.ruby-forum.com/u/ric)\
**Post date:** [June 27, 2008, 8:15am UTC](https://www.ruby-forum.com/t/missing-c-based-mysql-library-for-mac-os-x/128661/8 "2008-06-27T08:15:06Z")

</div>

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
