我正在尝试安装mysql gem以便在rails上使用,使用jruby,无法想出来......任何帮助都表示赞赏!
$ sudo gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/masedesign/Work/repos/code/conf/vms/ruby/jruby/bin/jruby extconf.rb
WARNING: JRuby does not support native extensions or the `mkmf' library very well.
Check http://kenai.com/projects/jruby/pages/Home for alternatives.
checking for rb_thread_blocking_region()... 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
cc -I. -I. -I/Users/masedesign/Work/repos/code/conf/vms/ruby/jruby/lib/native/include/ruby -I. -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/mysql/include -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fPIC -DTARGET_RT_MAC_CFM=0 -fno-omit-frame-pointer -fno-strict-aliasing -fexceptions -Wall -funroll-loops -arch x86_64 -c client.c
cc -I. -I. -I/Users/masedesign/Work/repos/code/conf/vms/ruby/jruby/lib/native/include/ruby -I. -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/mysql/include -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fPIC -DTARGET_RT_MAC_CFM=0 -fno-omit-frame-pointer -fno-strict-aliasing -fexceptions -Wall -funroll-loops -arch x86_64 -c mysql2_ext.c
cc -I. -I. -I/Users/masedesign/Work/repos/code/conf/vms/ruby/jruby/lib/native/include/ruby -I. -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/mysql/include -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fPIC -DTARGET_RT_MAC_CFM=0 -fno-omit-frame-pointer -fno-strict-aliasing -fexceptions -Wall -funroll-loops -arch x86_64 -c result.c
cc -dynamic -bundle -undefined dynamic_lookup -o mysql2.bundle client.o mysql2_ext.o result.o -L"." -L"/Users/masedesign/Work/repos/code/conf/vms/ruby/jruby-1.6.5/lib" -bundle -framework JavaVM -Wl,-syslibroot, -mmacosx-version-min=10.4 -Wl,-rpath,/usr/local/mysql/lib -arch x86_64 -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc
ld: library not found for -lbundle1.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1
Gem files will remain installed in /Users/masedesign/Work/repos/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/mysql2-0.3.11 for inspection.
Results logged to /Users/masedesign/Work/repos/code/conf/vms/ruby/jruby-1.6.5/lib/ruby/gems/1.8/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
答案 0 :(得分:8)
mysql
宝石仅针对MRI(Ruby 1.8)开发和测试。因此,它在大多数实现中使用旧式C扩展。虽然它们在技术上受到JRuby的支持,但它们很慢并且容易出错。所以不要使用它们。
如果使用JRuby,那么使用使用java本机数据库接口的JDBC适配器会更好,因此更快,更好地支持。高级接口(例如Rails使用的)大致相同,你不应该注意到任何差异。
因此对于JRuby,您应该使用jdbc-mysql
gem,或者 - 如果您使用Rails - activerecord-jdbcmysql-adapter
gem,它需要gem并添加相应的数据库适配器。
答案 1 :(得分:0)