Gem 求教:安装 mysql2 gem 0.3.11 版本出错

rubyqian · 2012年02月09日 · 最后由 lb563 回复于 2012年04月28日 · 6855 次阅读

我的环境如下: 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.

你确定你的系统是 10.4?现在都 10.7 了啊 我觉得比较大的可能是你的 xcode 版本实在太老了。

同好奇围观,如果这样用,不如装个 Linux 了

10.4,多少年前了啊?

mysql2 和 mysql 是不一样的 gem

gem install mysql2 v=0.3.11

#1 楼 @ywencn 不是 xcode 的问题,是 mysql 包的问题。

#4 楼 @metal 对,我从 mysql 网站上重新下载安装。解决了。

#2 楼 @gene_wu 问题已经解决了。搞了我差不多 1 个礼拜的时间,终于把 rails on ruby 的环境搭好了。

#8 楼 @rubyqian 你好。。是 ruby on rails, 不是 rails on ruby ~, ~

#9 楼 @ywencn 哈哈哈,sorry! 可能我的语言表达有问题。很多成语我也会颠倒说。

#9 楼 @ywencn 求教:ajax 没有反应。我和http://ruby-china.org/topics/2083 这个发生一摸一样的问题。

#9 楼 @ywencn 对,这个值得纠正!呵呵

需要 登录 后方可回复, 如果你还没有账号请 注册新账号