Archive for April, 2011

LBFA is a hilarious webcomic about comicbooks. Some recent favourites: Batman vs. Martian Manhunter, Dr Doom or Ayn Rand?, Bill Sienkiewicz, X-Men: No Class and the realities of DC Universe Online.

Linking mysql gem to MAMP

April 6, 2011  |  Tags: ,   |  

I was referring to instructions on Guard’s Blog on how to link the installed mysql Ruby gem to the latest version of MAMP. His entry is great — it’s updated for Cmake, whereas previous versions were for Make.

However, I kept running into a problem where the gem would look for MySQL libraries in the compile directory instead of the MAMP directory, i.e. the gem would complain of "Library not loaded: /tmp/mysql-5.5.9/libmysql/libmysqlclient.16.dylib (LoadError)" if I moved my compile directory away from where it started out (in this case, /tmp/mysql-5.5.9).

I finally got it to work, thanks to the answer in this Stack Overflow question. Full instructions below, copied from Guard’s Blog (thanks!):

First, download MAMP sources, and mount. Then enter the following commands in

$ cd /tmp
$ cp /Volumes/MAMP_src/mysql-5.5.9.tar.gz .
$ tar xf mysql-5.5.9.tar.gz
$ cd mysql-5.5.9
$ sudo port install cmake
$ cmake . -DMYSQL_UNIX_ADDR=/Applications/MAMP/tmp/mysql/mysql.sock -DCMAKE_INSTALL_PREFIX=/Applications/MAMP/Library
$ make -j 2
$ cp libmysql/*.dylib /Applications/MAMP/Library/lib/
$ mkdir -p /Applications/MAMP/Library/include/mysql
$ cp include/* /Applications/MAMP/Library/include/mysql
$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
$ sudo install_name_tool -change /tmp/mysql-5.5.9/libmysql/libmysqlclient.16.dylib /Applications/MAMP/Library/lib/libmysqlclient.16.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
$ cd /tmp
$ rm mysql-5.5.9 # To ensure this isn't the one being linked to

If you’re using RVM, you’ll need to adapt the last argument of that last line to something like ~/.rvm/gems/ruby-1.9.2/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle.

Wow, major nerd pride overload here. Well done, Manek. I’m looking forward to more great things from you.

Colbert sang with such genuine emotion, I nearly cried when he “saw his friends”.

(Replaced with NBC video, after they pulled the YouTube one. Idiots.)