2012-03-26 14 views
6

Estoy tratando de instalar mysql gem para usar en rieles, usando jruby, no puedo resolverlo ... ¡se agradece cualquier ayuda!muchos errores al instalar mysql en 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 

Respuesta

8

La gema mysql fue desarrollada y probada solo contra MRI (Ruby 1.8). Como tal, utiliza extensiones C de estilo antiguo para la mayor parte de su implementación. Si bien técnicamente son compatibles con JRuby, son lentos y propensos a errores. Entonces no los uses.

Si usa JRuby, está mucho mejor usando los adaptadores JDBC que utilizan la interfaz de base de datos java-native y, por lo tanto, son mucho más rápidos y están mejor respaldados. La interfaz de alto nivel (como, por ejemplo, utilizada por Rails) es más o menos la misma, no debe notar ninguna diferencia.

Por lo tanto, para JRuby debe usar la gema jdbc-mysql o, si usa Rails, la gema activerecord-jdbcmysql-adapter que requiere esa gema y agrega el adaptador de base de datos adecuado.

0

Parece que esto aparece de vez en cuando. Aquí hay un SO post con algo de información (la segunda y la tercera respuestas son más de lo que está buscando).

En otra nota this blog sugiere usar jdbc-mysql.