尝试在 CentOS 6.4 x64 上安装 mysql2 gem,并使用 rpm 安装 MySQL 5.6。
得到这个:
Installing mysql2 (0.3.11)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/rbenv/versions/1.9.3-p448/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile
make
compiling mysql2_ext.c
compiling result.c
compiling client.c
client.c: In function Б─≤rb_raise_mysql2_errorБ─≥:
client.c:98: warning: ISO C90 forbids mixed declarations and code
client.c: In function Б─≤rb_mysql_client_socketБ─≥:
client.c:590: warning: ISO C90 forbids mixed declarations and code
linking shared-object mysql2/mysql2.so
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
make: *** [mysql2.so] Error 1
Gem files will remain installed in /usr/local/rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11 for inspection.
Results logged to /usr/local/rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
An error occurred while installing mysql2 (0.3.11), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.
编辑:
来自 ldconfig -p 的响应 | grep mysql
libmysqlclient_r.so.16 (libc6,x86-64) => /usr/lib64/libmysqlclient_r.so.16
libmysqlclient_r.so.15 (libc6,x86-64) => /usr/lib64/libmysqlclient_r.so.15
libmysqlclient_r.so.14 (libc6,x86-64) => /usr/lib64/libmysqlclient_r.so.14
libmysqlclient_r.so.12 (libc6,x86-64) => /usr/lib64/libmysqlclient_r.so.12
libmysqlclient.so.16 (libc6,x86-64) => /usr/lib64/libmysqlclient.so.16
libmysqlclient.so.15 (libc6,x86-64) => /usr/lib64/libmysqlclient.so.15
libmysqlclient.so.14 (libc6,x86-64) => /usr/lib64/libmysqlclient.so.14
libmysqlclient.so.12 (libc6,x86-64) => /usr/lib64/libmysqlclient.so.12