# "gem install mysql" failing horribly on OS X leaopard

**URL:** <https://www.ruby-forum.com/t/gem-install-mysql-failing-horribly-on-os-x-leaopard/147949>\
**Category:** Ruby\
**Created:** [September 7, 2008, 1:53pm UTC](https://www.ruby-forum.com/t/gem-install-mysql-failing-horribly-on-os-x-leaopard/147949 "2008-09-07T13:53:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![biot023](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@biot023](https://www.ruby-forum.com/u/biot023)\
**Post date:** [September 7, 2008, 1:53pm UTC](https://www.ruby-forum.com/t/gem-install-mysql-failing-horribly-on-os-x-leaopard/147949/1 "2008-09-07T13:53:42Z")

</div>

Hi – I’m having trouble getting the mysql gem to install on an OS X  
Leopard machine.  
Typical output I get from the console is this:

esft 523 $ sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-include=/usr/local/mysql/include --with-mysql-lib=/usr/local/mysql/lib Password: Building native extensions. This could take a while... ERROR: Error installing mysql: ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install mysql –  
–with-mysql-include=/usr/local/mysql/include  
–with-mysql-lib=/usr/local/mysql/lib  
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  
\*\*\* 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=/usr/local/bin/ruby  
–with-mysql-config  
–without-mysql-config  
–with-mysql-dir  
–without-mysql-dir  
–with-mysql-include=${mysql-dir}/include  
–with-mysql-lib=${mysql-dir}/lib  
–with-mysqlclientlib  
–without-mysqlclientlib  
–with-mlib  
–without-mlib  
–with-mysqlclientlib  
–without-mysqlclientlib  
–with-zlib  
–without-zlib  
–with-mysqlclientlib  
–without-mysqlclientlib  
–with-socketlib  
–without-socketlib  
–with-mysqlclientlib  
–without-mysqlclientlib  
–with-nsllib  
–without-nsllib  
–with-mysqlclientlib  
–without-mysqlclientlib

Gem files will remain installed in  
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.  
Results logged to  
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem\_make.out

And when I look in the mkmf.log file, at the end of a very long series  
of entries, I see this:

"gcc -o conftest -I. -I/usr/local/lib/ruby/1.8/universal-darwin8.0 -I. -I/usr/local/mysql/include -I/usr/local/include -g -O2 -fno-common -pipe -fno-common conftest.c -L"/usr/local/lib" -L"/usr/local/mysql/lib" -L"/usr/local/lib" -L"/usr/local/lib/mysql" -arch i386 -lz -lm -lruby-static -lmysqlclient -lz -lm -lpthread -ldl -lobjc " ld: warning in /usr/local/mysql/lib/libmysqlclient.dylib, file is not of required architecture Undefined symbols: "\_mysql\_query", referenced from: \_t in ccxGmlzF.o ld: symbol(s) not found collect2: ld returned 1 exit status checked program was: /\* begin \*/ 1: /\*top\*/ 2: int main() { return 0; } 3: int t() { mysql\_query(); return 0; } /\* end \*/
* * *

Can anyone offer me any advice on getting this to work?  
Cheers,  
Doug.

---

<div class="post-metadata">

**Author:** ![biot023](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@biot023](https://www.ruby-forum.com/u/biot023)\
**Post date:** [September 7, 2008, 2:58pm UTC](https://www.ruby-forum.com/t/gem-install-mysql-failing-horribly-on-os-x-leaopard/147949/2 "2008-09-07T14:58:08Z")

</div>

On 7 Sep 2008, at 12:47, Doug L. wrote:

> ld: warning in /usr/local/mysql/lib/libmysqlclient.dylib, file is  
> not of  
> required architecture

This appears to be the key bit: you’re asking for an i386 executable  
but that library is apparently a different architecture (lipo -  
detailed\_info /usr/local/mysql/lib/libmysqlclient.dylib will tell you  
what it is)

Fred

---

<div class="post-metadata">

**Author:** ![biot023](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@biot023](https://www.ruby-forum.com/u/biot023)\
**Post date:** [September 7, 2008, 3:32pm UTC](https://www.ruby-forum.com/t/gem-install-mysql-failing-horribly-on-os-x-leaopard/147949/3 "2008-09-07T15:32:28Z")

</div>

Cheers for that – could it be I have installed the wrong version of  
MySQL?  
I grabbed it when I’d just got my Mac & had never used one before.  
The results from typing in what you suggest are:

input file /usr/local/mysql/lib/libmysqlclient.dylib is not a fat file  
Non-fat file: /usr/local/mysql/lib/libmysqlclient.dylib is architecture:  
ppc

That looks to me like I should maybe reinstall MySQL with the proper  
DMG?  
& thanks for your help,  
Doug.

---

<div class="post-metadata">

**Author:** ![biot023](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@biot023](https://www.ruby-forum.com/u/biot023)\
**Post date:** [November 16, 2009, 10:17am UTC](https://www.ruby-forum.com/t/gem-install-mysql-failing-horribly-on-os-x-leaopard/147949/4 "2009-11-16T10:17:24Z")

</div>

Can you try the following command.

sudo env ARCHFLAGS=’-arch i386’ gem install mysql -v=2.7 –  
–with-mysql-config=/usr/local/mysql/bin/mysql\_config

Kem Mason wrote:

> Frederick C. wrote:
> 
> > On 7 Sep 2008, at 12:47, Doug L. wrote:
> > 
> > > ld: warning in /usr/local/mysql/lib/libmysqlclient.dylib, file is  
> > > not of  
> > > required architecture
> > 
> > This appears to be the key bit: you’re asking for an i386 executable  
> > but that library is apparently a different architecture (lipo -  
> > detailed\_info /usr/local/mysql/lib/libmysqlclient.dylib will tell you  
> > what it is)
> > 
> > Fred
> 
> I did this, and my libmysqlclient.dylib was i386 – but I noticed the  
> compiler commands were:
> 
> gcc -I. -I.  
> -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0  
> -I. -DHAVE\_MYSQL\_H -I/usr/local/mysql/include -Os -arch i386  
> -fno-common -fno-common -arch ppc -arch i386 -Os -pipe -fno-common -c  
> mysql.c  
> cc -arch ppc -arch i386 -pipe -bundle -undefined dynamic\_lookup -o  
> mysql.bundle mysql.o -L"."  
> -L"/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib" -L.  
> -arch ppc -arch i386 -lruby -L/usr/local/mysql/lib -lmysqlclient -lz  
> -lm -lpthread -ldl -lm  
> #output:  
> ld warning: in /usr/local/mysql/lib/libmysqlclient.dylib, file is not of  
> required architecture
> 
> I copy / pasted the commands stripping out all the ‘-arch ppc’  
> instances, and everything worked great for me after that.

---

<div class="post-metadata">

**Author:** ![biot023](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@biot023](https://www.ruby-forum.com/u/biot023)\
**Post date:** [April 12, 2009, 9:19pm UTC](https://www.ruby-forum.com/t/gem-install-mysql-failing-horribly-on-os-x-leaopard/147949/5 "2009-04-12T21:19:57Z")

</div>

Frederick C. wrote:

> On 7 Sep 2008, at 12:47, Doug L. wrote:
> 
> > ld: warning in /usr/local/mysql/lib/libmysqlclient.dylib, file is  
> > not of  
> > required architecture
> 
> This appears to be the key bit: you’re asking for an i386 executable  
> but that library is apparently a different architecture (lipo -  
> detailed\_info /usr/local/mysql/lib/libmysqlclient.dylib will tell you  
> what it is)
> 
> Fred

I did this, and my libmysqlclient.dylib was i386 – but I noticed the  
compiler commands were:

gcc -I. -I.  
-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0  
-I. -DHAVE\_MYSQL\_H -I/usr/local/mysql/include -Os -arch i386  
-fno-common -fno-common -arch ppc -arch i386 -Os -pipe -fno-common -c  
mysql.c  
cc -arch ppc -arch i386 -pipe -bundle -undefined dynamic\_lookup -o  
mysql.bundle mysql.o -L"."  
-L"/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib" -L.  
-arch ppc -arch i386 -lruby -L/usr/local/mysql/lib -lmysqlclient -lz  
-lm -lpthread -ldl -lm  
#output:  
ld warning: in /usr/local/mysql/lib/libmysqlclient.dylib, file is not of  
required architecture

I copy / pasted the commands stripping out all the ‘-arch ppc’  
instances, and everything worked great for me after that.
