views:

698

answers:

2

Hello all,

I've never used the ARCHFLAGS command before and am in way over my head.

I'm struggling with getting the MySQL gem working on Snow Leopard in 64 bit.

What I'm doing is this command:

sudo env ARCHFLAGS='-arch x86_64' gem install --verbose --no-rdoc --no-ri mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

The output looks like this:

.....
make
gcc -I. -I. -I/usr/local/lib/ruby/1.8/universal-darwin8.0 -I. -DHAVE_RB_THREAD_START_TIMER -DHAVE_MYSQL_H  -I/usr/local/mysql/include/mysql -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT  -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common -g -O2  -fno-common -pipe -fno-common  -arch i386 -c mysql.c
cc -dynamic -bundle -undefined suppress -flat_namespace -arch i386 -L"/usr/local/lib" -o mysql_api.bundle mysql.o  -lruby -L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm  -lpthread -ldl -lobjc  
ld: warning: in /usr/local/mysql/lib/mysql/libmysqlclient.dylib, file is not of required architecture

make install
/usr/bin/install -c -m 0755 mysql_api.bundle /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib
Successfully installed mysql-2.8.1
1 gem installed

What I see is that it specifically specifies -arch i386 even though I'm telling it not to; directly after, it gives me the warning about the file not being the required architecture, because it's not. It's 64 bit.

Running the file command gives this:

file /usr/local/mysql/lib/mysql/libmysqlclient.dylib 
/usr/local/mysql/lib/mysql/libmysqlclient.dylib: Mach-O 64-bit dynamically linked shared library x86_64

So of course it's not the required architecture. It seems that the gem install is ignoring my ARCHFLAGS command. Any idea why this would be? Like I said, I'm in way over my head on this stuff :P

Thanks so much all! - Kevin

A: 

Have you reviewed the comments at Rails + MySQL on Snow Leopard

There is a lot of discussion around the setup and installation which may assist. I build the MySQL binaries from source following advice from Build MySQL on Snow Leopard.

Grant Sayer
Yes, I've built the MySQL binaries from source. When I run the 'file' command it says it's built in x86_64 so I'm thinking that's correct. And I've followed all the other instructions as far as I can
thekevinscott
But I should add, I have no idea - this is all very new to me, so please feel free to correct me if I'm wrong. It would *seem* like the archflags parameter I'm passing in is not being taken, though, right? Or no?
thekevinscott
A: 

Here's what I did:

export ARCHFLAGS="-arch i386 -arch x86_64"

sudo gem install --no-rdoc --no-ri mysql -v 2.7 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

I specified version 2.7 because there seemed to be a problem with subsequent versions. I'd try the latest version and see if it works first.

stretchwithme