经过无数次尝试,我以某种方式设法在 OSX Mavericks(Ruby 2.0 附带)上使用 rbenv 安装了 Ruby 1.8.7。
但是,我在安装 mysql2 时遇到了一个我很难理解的错误。有人可以指出我解决这个问题的方向吗?请看下面的输出:
$ sudo gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/myuser/.rbenv/versions/1.8.7-p370/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... no
checking for rb_hash_dup()... no
checking for rb_intern3()... no
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile
make
/usr/local/bin/gcc-4.2 -I. -I. -I/Users/myuser/.rbenv/versions/1.8.7-p370/lib/ruby/1.8/i686-darwin13.0.0 -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I'/Users/myuser/.rbenv/versions/1.8.7-p370/include' -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I'/Users/myuser/.rbenv/versions/1.8.7-p370/include' -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include -I/usr/local/mysql/include -Os -g -fno-strict-aliasing -arch x86_64 -fno-common -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib -O3 -Wno-error=shorten-64-to-32 -pipe -fno-common -Wall -funroll-loops -c client.c
In file included from client.c:1:
./mysql2_ext.h:13: error: redefinition of typedef ‘ushort’
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/sys/types.h:91: error: previous declaration of ‘ushort’ was here
./mysql2_ext.h:14: error: redefinition of typedef ‘uint’
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/sys/types.h:92: error: previous declaration of ‘uint’ was here
client.c: In function ‘set_charset_name’:
client.c:1045: warning: unused variable ‘mysql2rb’
make: *** [client.o] Error 1
Gem files will remain installed in /Users/myuser/.rbenv/versions/1.8.7-p370/lib/ruby/gems/1.8/gems/mysql2-0.3.13 for inspection.
Results logged to /Users/myuser/.rbenv/versions/1.8.7-p370/lib/ruby/gems/1.8/gems/mysql2-0.3.13/ext/mysql2/gem_make.out