sudo gem install mysql2
dyld: DYLD_ environment variables being ignored because main
executable (/usr/bin/sudo) is setuid or setgid
Password:
Building native extensions. This could take
a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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
xcrun cc -I. -I.
-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0
-I. -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_RB_WAIT_FOR_SINGLE_FD
-DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H
-D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
-I/usr/local/mysql/include -Os
-g -fno-common -fno-strict-aliasing -arch x86_64 -fno-common -arch
i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE
-fno-common -pipe -fno-common
-Wall -funroll-loops -c
client.c
xcrun: Error: could not stat active Xcode path
'/Volumes/Xcode/Xcode.app/Contents/Developer'. (No such file or
directory)
xcrun cc -I. -I.
-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0
-I. -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_RB_WAIT_FOR_SINGLE_FD
-DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H
-D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
-I/usr/local/mysql/include -Os
-g -fno-common -fno-strict-aliasing -arch x86_64 -fno-common -arch
i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE
-fno-common -pipe -fno-common
-Wall -funroll-loops -c
mysql2_ext.c
xcrun: Error: could not stat active Xcode path
'/Volumes/Xcode/Xcode.app/Contents/Developer'. (No such file or
directory)
xcrun cc -I. -I.
-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0
-I. -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_RB_WAIT_FOR_SINGLE_FD
-DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H
-D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
-I/usr/local/mysql/include -Os
-g -fno-common -fno-strict-aliasing -arch x86_64 -fno-common -arch
i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE
-fno-common -pipe -fno-common
-Wall -funroll-loops -c
result.c
xcrun: Error: could not stat active Xcode path
'/Volumes/Xcode/Xcode.app/Contents/Developer'. (No such file or
directory)
cc -arch i386 -arch x86_64 -pipe -bundle -undefined
dynamic_lookup -o mysql2.bundle client.o mysql2_ext.o result.o -L.
-L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib
-L. -arch i386 -arch x86_64
-Wl,-rpath,/usr/local/mysql/lib
-lruby -L/usr/local/mysql/lib
-lmysqlclient_r -lpthread
-lpthread -ldl -lobjc
clang: error: no such file or directory: 'client.o'
clang: error: no such file or directory: 'mysql2_ext.o'
clang: error: no such file or directory: 'result.o'
make: *** [mysql2.bundle] Error 1
解决办法: sudo xcode-select -switch
/Applications/Xcode.app
sudo gem install mysql2 --platform=ruby --
--with-mysql-dir=/usr/local/mysql
--with-mysql-lib=/usr/local/mysql/lib
–with-mysql-include=/usr/local/mysql/include
--with-mysql-config=/usr/local/mysql/bin/mysql_config