[Rubygems-developers] Problems compiling native gems under Snow Leopard + Homebrew

Chad Woolley thewoolleyman at gmail.com
Tue Jun 29 03:23:33 EDT 2010

(also at http://gist.github.com/456916)

Hopefully somebody here can help with this, I've asked a few other
places with no success.

I've got Snow Leopard running on an older macbook, with Homebrew.

My problem is that some native gems have problems compiling for the
correct architecture when I use a compiled ruby (e.g. RVM) instead of
the system ruby.

Under System ruby, it works (mysql_api.bundle can load):

$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -v 2.8.1 --
$ file /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/mysql_api.bundle
Mach-O 64-bit bundle x86_64
$ ruby -e "require

Under RVM 1.8.7, it fails (wrong architecture when loading mysql_api.bundle):

$ rvm use 1.8.7 at test1
info: Using ruby 1.8.7 p174 with gemset test1
$ env ARCHFLAGS="-arch x86_64" gem install mysql -v 2.8.1 --
$ file /Users/woolley/.rvm/gems/ruby-1.8.7-p174 at test1/gems/mysql-2.8.1/ext/mysql_api/mysql_api.bundle
/Users/woolley/.rvm/gems/ruby-1.8.7-p174 at test1/gems/mysql-2.8.1/ext/mysql_api/mysql_api.bundle:
Mach-O 64-bit bundle x86_64
$ ruby -e "require
'/Users/woolley/.rvm/gems/ruby-1.8.7-p174 at test1/gems/mysql-2.8.1/ext/mysql_api/mysql_api.bundle'"
/Users/woolley/.rvm/gems/ruby-1.8.7-p174 at test1/gems/mysql-2.8.1/ext/mysql_api/mysql_api.bundle:
dlopen(/Users/woolley/.rvm/gems/ruby-1.8.7-p174 at test1/gems/mysql-2.8.1/ext/mysql_api/mysql_api.bundle,
9): no suitable image found.  Did find: (LoadError)
	/Users/woolley/.rvm/gems/ruby-1.8.7-p174 at test1/gems/mysql-2.8.1/ext/mysql_api/mysql_api.bundle:
mach-o, but wrong architecture -
/Users/woolley/.rvm/gems/ruby-1.8.7-p174 at test1/gems/mysql-2.8.1/ext/mysql_api/mysql_api.bundle
	from -e:1

Here's the error from mkmf.log:

"gcc -o conftest -I.
-I/usr/local/Cellar/mysql/5.1.47/include/mysql   -D_P1003_1B_VISIBLE
-fno-common   conftest.c  -L.
-L/Users/woolley/.rvm/rubies/ruby-1.8.7-p174/lib -L.
-L/usr/local/Cellar/mysql/5.1.47/lib/mysql -lmysqlclient
-lz -lm  -lruby-static -L/usr/local/Cellar/readline/6.0/lib
-L/usr/local/Cellar/mysql/5.1.47/lib/mysql -lmysqlclient -lz -lm  -ldl
-lobjc  "
ld: warning: in
/Users/woolley/.rvm/rubies/ruby-1.8.7-p174/lib/libruby-static.a, file
was b
uilt for unsupported file format which is not the architecture being
linked (x86_64)
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { mysql_ssl_set(); return 0; }
/* end */

Looking at the 'file' architecture for other .bundle files is
inconclusive.  Some are i386, some of x86_64, and the apple-provided
ones are universal/multi architecture.

Looking at these two links, I'm not even sure which one my machine
should be.  I can't boot into 64-bit kernel by holding 6+4 when I
boot, which makes sense since my machine is not on the list in the
second article:


I don't know enough to dig into the C compilation and debug what is
wrong.  Any help is appreciated.

-- Chad

More information about the Rubygems-developers mailing list