我的环境如下: Mac OS 10.4.11, Ruby 1.8.7 Rails 3.2.1, Gem 1.8.15 数据库 mysql5 Ver 14.14 Distrib 5.1.61, for apple-darwin8.11.1 (i386) using gem 包: mysql (2.8.1)
当我执行 rails new demo 命令时出现:
Installing mysql2 (0.3.11) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.
/opt/local/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... no
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile
make
/usr/bin/gcc-4.0 -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin8 -I. -
DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/opt/local/
include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/opt/local/include -I/
opt/local/include/mysql5/mysql -fPIC -D_P1003_1B_VISIBLE -
DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -
DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common -
O2 -arch i386 -fno-common -pipe -fno-common -Wall -funroll-loops -
arch i386 -c client.c
/usr/bin/gcc-4.0 -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin8 -I. -
DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/opt/local/
include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/opt/local/include -I/
opt/local/include/mysql5/mysql -fPIC -D_P1003_1B_VISIBLE -
DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -
DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common -
O2 -arch i386 -fno-common -pipe -fno-common -Wall -funroll-loops -
arch i386 -c mysql2_ext.c
./client.h:20: warning: ‘rb_thread_blocking_region’ defined but not
used
/usr/bin/gcc-4.0 -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin8 -I. -
DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/opt/local/
include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/opt/local/include -I/
opt/local/include/mysql5/mysql -fPIC -D_P1003_1B_VISIBLE -
DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -
DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common -
O2 -arch i386 -fno-common -pipe -fno-common -Wall -funroll-loops -
arch i386 -c result.c
/usr/bin/gcc-4.0 -dynamic -bundle -undefined suppress -flat_namespace -
o mysql2.bundle client.o mysql2_ext.o result.o -L. -L/opt/local/lib -L/
opt/local/lib -L. -L/opt/local/lib -arch i386 -Wl,-rpath,/opt/local/
lib -arch i386 -lruby -L/opt/local/lib -L/opt/local/lib/mysql5/
mysql -lmysqlclient_r -L/opt/local/lib -lz -lm -L/opt/local/lib/ -
lssl -lcrypto -lpthread -ldl -lobjc
/usr/bin/ld: unknown flag: -rpath
collect2: ld returned 1 exit status
make: *** [mysql2.bundle] Error 1
Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/
mysql2-0.3.11 for inspection.
Results logged to /opt/local/lib/ruby/gems/1.8/gems/mysql2-0.3.11/ext/
mysql2/gem_make.out
An error occured while installing mysql2 (0.3.11), and Bundler cannot
continue.
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before
bundling.