Rails 2.0 on MacOS 10.4.11
MySQLとつなげるべく、database.ymlに記載されているように
$ sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
を実行したが、以下のようなエラーが出てコンパイルに失敗する。
gcc -I. -I. -I/usr/local/lib/ruby/1.8/i686-darwin8.9.1 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -I/usr/local/mysql/include -fno-common -g -O2 -pipe -fno-common -c mysql.c mysql.c: In function 'Init_mysql': mysql.c:2015: error: 'ulong' undeclared (first use in this function) mysql.c:2015: error: (Each undeclared identifier is reported only once mysql.c:2015: error: for each function it appears in.) mysql.c:2015: error: parse error before numeric constant mysql.c:2018: error: parse error before numeric constant make: *** [mysql.o] Error 1
原因
ulongが定義されていないため。以下の方法でごまかす。
$ cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/ $ vi mysql.c #先頭に以下の行を記述 #define ulong unsigned long #以下を実行 $ sudo make $ sudo make install