I spent too long today trying to get merb running on a CentOS box because I had to jump through a lot of hoops to get the do_mysql-0.9.6 gem installed. I’m not really sure how to even sum up all the dead ends and changes I had to make, but I’ll try in the hopes of helping someone else (maybe myself in a month when I forget all this).I was trying for a long time to get the gem installed with a gem install, but ended up having to pull down the source and manually compile and install.Since we have our mysql libs in a non-standard dir on this box, I tried passing them as args to the initial install:
gem install -- --with-mysql-include=/usr/local/src/mysql-5.0.62/include/ --with-mysql-lib=/usr/local/src/mysql-5.0.62/lib/
but got something like this:
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_MYSQL_QUERY -DHAVE_MYSQL_SSL_SET -I/usr/include/mysql -g -pipe -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fPIC -g -O2 -Wall -c do_mysql_ext.cdo_mysql_ext.c: In function `cConnection_initialize':do_mysql_ext.c:464: error: `MYSQL_OPT_RECONNECT' undeclared (first use in this function)do_mysql_ext.c:464: error: (Each undeclared identifier is reported only oncedo_mysql_ext.c:464: error: for each function it appears in.)make: *** [do_mysql_ext.o] Error 1
I found a few forum posts online and decided to statically set the MYSQL_OPT_RECONNECT variable on line 464 of ext/do_mysql_ext.c to TRUE which got me past that error, but no glory quite yet. I then had to edit line 46 of the generated Makefile to look in my mysql include dir since that didn’t seem to take from my initial gem call:
CPPFLAGS = -DHAVE_MYSQL_H -DHAVE_MYSQL_QUERY -DHAVE_MYSQL_SSL_SET -I/usr/local/src/mysql-5.0.62/include -g -pipe -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing
Things seemed to be ok, but another install attempt failed because of some missing hoe tasks referenced by the Rakefile. Apparently they are only in the full data_objects code (tasks/hoe.rb)…so the next step was to pull down the complete data_objects source.A straight rake install didn’t work even after the Makefile and do_mysql_ext.c edits. I was getting this error:
undefined method `add_development_dependency' for #<gem></gem>
Thanks to this page, I discovered it was related to my “old” version of rake (1.1.1). So I upgraded to rake ver 1.3 and re-ran the install - still no go!I decided to just run each data_objects pkg one at a time. I first did this:
cd data_objects && rake install
…which worked!Then:
cd ../do_mysql && rake install
Which also worked! So, a recap:
- Download full data_objects source
- Upgrade rake to at least 1.2
- Install just data_objects gem
- Try to install do_mysql, if fails, edit Makefile and do_mysql_ext.c
I know that’s pretty convoluted, so leave a comment if you’re having the same issue and want more details.



