söndag 5 april 2009

Error installing mysql gem

Ususally when writing rails apps, I always use sqlite3 in development but for a recent project we use the sphinx search engine
which requires that you use either a postgres or mysql database engine.
Now, I've tried setting up postgres in the past and it was, to say the least, a painful experience and I never really got it working
so I figured I'd give mysql a try.
Being the lazy person that I am, I took a little shortcut and instead of building from source, I downloaded the mysql package
and installed it and everything seemed to work just fine, I could access mysql, add accounts, create databases and so on.
So the next step was to install the mysql gem and this is what happened:

Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.


After some debugging and a lot of googling I managed to fix it by running this:

sudo bash -c "ARCHFLAGS='-arch i386' sudo gem install mysql -- --with-mysql-include=/usr/local/mysql-5.1.33-osx10.5-x86/include --with-mysql-lib=/usr/local/mysql-5.1.33-osx10.5-x86/lib/lib --with-mysql-config=/usr/local/mysql-5.1.33-osx10.5-x86/bin/mysql_config"


Inga kommentarer:

Skicka en kommentar