<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener("load", function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <iframe src="http://www.blogger.com/navbar.g?targetBlogID=7625526986034013157&amp;blogName=Tim,+the+Enchanter&amp;publishMode=PUBLISH_MODE_HOSTED&amp;navbarType=BLUE&amp;layoutType=CLASSIC&amp;searchRoot=http://tim.theenchanter.com/search&amp;blogLocale=en&amp;homepageUrl=http://tim.theenchanter.com/&amp;vt=-6946124640953606865" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="30px" width="100%" id="navbar-iframe" allowtransparency="true" title="Blogger Navigation and Search"></iframe> <div></div>

About

I'm a ruby developer passionate about developing clean code that makes for programming happiness. I'm also am passionate about freedom, liberty, and capitalism, and enjoy jamming out some good rock or jazz on the piano.

I'm a family man and a I'm a member of The Church of Jesus Christ of Latter Day Saints (AKA the "Mormons") and I wield a strong testimony of my Savior Jesus Christ (yes we're Christians).

I'm currently employed by:

Building MySQL multiarch (32/64 bit) client libraries on OS X Tuesday, November 30, 2010 |

Getting the mysql gem to build can be a pain. Especially if you have installed the 64-bit version of mysql and are using a 32-bit version of ruby

You can check the build arch of an executable/library via the file command, such as:

$ file `which ruby`
/Users/timcharper/Developer/.rvm/rubies/ruby-1.8.6-p383/bin/ruby: Mach-O executable i386
$ file /usr/local/mysql/lib/libmysqlclient.dylib 
/usr/local/mysql/lib/libmysqlclient.dylib: Mach-O 64-bit dynamically linked shared library x86_64

See how those disagree? If you're using homebrew (which you should be!), you can build the client libs/tools only (universal style) as follows:

brew install mysql --client-only --universal

Then, to install the gem, you need to pass some fancy flags to get the mysql gem to link against your new libraries:

HOMEBREW_PREFIX=/usr/local # if your prefix differs, modify this line

gem install mysql -- --with-opt-include=$HOMEBREW_PREFIX/include/mysql/ --with-opt-lib=$HOMEBREW_PREFIX/lib/mysql --without-mysql-config

Your gem should build with no errors, and your new shiny universal mysql client libraries should serve you well in the future if you use both 32-bit and 64-bit rubies.