安装 -- mysql2 gem 在使用 rbenv 和 Ruby 1.8.7 的 OSX Mavericks 上失败



经过无数次尝试,我不知何故设法在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

刚才我发现这个工作正常:

gem install mysql2 -- --with-cflags=\"-DHAVE_UINT\"

来源:安装 mysql2 gem - HAVE_UINT(ushort,uint 类型重定义错误)

最新更新