[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 --
--with-mysql-config=/usr/local/bin/mysql_config
$ file /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/mysql_api.bundle
/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
'/Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/mysql_api.bundle'"

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 --
--with-mysql-config=/usr/local/bin/mysql_config
$ 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/Users/woolley/.rvm/rubies/ruby-1.8.7-p174/lib/ruby/1.8/i686-darwin9.6.0
-I.  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
-I/usr/local/Cellar/mysql/5.1.47/include/mysql   -D_P1003_1B_VISIBLE
-DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ
-DIGNORE_SIGHUP_SIGQUIT  -DDONT_DECLARE_CXA_PURE_VIRTUAL -g -O2 -pipe
-fno-common   conftest.c  -L.
-L/Users/woolley/.rvm/rubies/ruby-1.8.7-p174/lib -L.
-L/usr/local/Cellar/readline/6.0/lib
-L/usr/local/Cellar/readline/6.0/lib
-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/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:

http://www.macobserver.com/tmo/article/checking_32_or_64-bit_kernel_boot_mode_in_snow_leopard/
http://www.osnews.com/story/22009/Snow_Leopard_Seeds_Use_32bit_Kernel_Drivers_by_Default

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

Thanks,
-- Chad


More information about the Rubygems-developers mailing list