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

时间:2013-10-25 19:36:47

标签: ruby xcode macos mysql2 rbenv

我在无数次尝试后,设法在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

1 个答案:

答案 0 :(得分:0)

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

gem install mysql2 - --with-cflags = \“ - DHAVE_UINT \”

来源:Installing mysql2 gem - HAVE_UINT (ushort, uint type redefinition errors)

相关问题