Home > スクリプト > Ruby Archive

Ruby Archive

rubygems - mysqlアダプタがインストール出来ない

mac OSX 10.4 にgemでmysql2.7のネイティブアダプタがインストール出来ない場合。

sudo gem install mysql — –with-mysql-dir=/usr/local/mysql

Select which gem to install for your platform (i686-darwin8.11.1)
1. mysql 2.7.3 (mswin32)
2. mysql 2.7.1 (mswin32)
3. mysql 2.7 (ruby)
4. mysql 2.6 (ruby)
5. Skip this gem
6. Cancel installation
> Building native extensions. This could take a while…
ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

ruby extconf.rb install mysql — –with-mysql-dir=/usr/local/mysql
checking for mysql_query() in -lmysqlclient… yes
checking for mysql_ssl_set()… yes
checking for mysql.h… yes
creating Makefile

make
gcc -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin8.11.1 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -I/usr/local/mysql/include -I/opt/local/include -fno-common -O2 -fno-common -pipe -fno-common -c mysql.c
mysql.c: In function ‘query’:
mysql.c:635: error: invalid storage class for function ‘res_free’
mysql.c:637: error: ‘res_free’ undeclared (first use in this function)
mysql.c:637: error: (Each undeclared identifier is reported only once
mysql.c:637: error: for each function it appears in.)
mysql.c: In function ‘Init_mysql’:
mysql.c:1299: error: ‘ulong’ undeclared (first use in this function)
mysql.c:1299: error: parse error before numeric constant
mysql.c:1302: error: parse error before numeric constant
make: *** [mysql.o] Error 1

Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

と、エラーを吐く。
以下、解決法↓

sudo vim /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/mysql.c.in.
ファイル先頭に
#define ulong unsigned long
と記述。

cd /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7
sudo ruby extconf.rb –with-mysql-config=/usr/local/mysql/bin/mysql_config
sudo make
sudo make install

以上。メモ。

Home > スクリプト > Ruby Archive

Search
Feeds
Meta

Return to page top