RoR+;XAMPP+;MySQL——Gem安装MySQL问题

RoR+;XAMPP+;MySQL——Gem安装MySQL问题,mysql,ruby-on-rails,ruby,Mysql,Ruby On Rails,Ruby,我是PHP开发者,我与XAMPP合作。我现在决定深入研究Ruby,我想使用XAMPP for Ruby中的MySQL安装,但在正确安装Gem for MySQL时遇到了一个问题 我正在执行的命令如下: sudo gem install mysql -- —–with-mysql-config=/Applications/XAMPP/xamppfiles/bin/mysql_config Gem::Ext::BuildError: ERROR: Failed to build gem nativ

我是PHP开发者,我与XAMPP合作。我现在决定深入研究Ruby,我想使用XAMPP for Ruby中的MySQL安装,但在正确安装Gem for MySQL时遇到了一个问题

我正在执行的命令如下:

sudo gem install mysql -- —–with-mysql-config=/Applications/XAMPP/xamppfiles/bin/mysql_config
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150126-99463-2b5bwp.rb extconf.rb 
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... yes
checking for rb_thread_start_timer()... no
checking for mysql.h... yes
clang: warning: argument unused during compilation: '-L/Applications/XAMPP/xamppfiles/lib'
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling mysql.c
clang: warning: argument unused during compilation: '-L/Applications/XAMPP/xamppfiles/lib'
linking shared-object mysql/mysql_api.bundle
ld: library not found for -lmysqlclient
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql_api.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/mysql-2.9.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-14/2.0.0/mysql-2.9.1/gem_make.out
An error occurred while installing mysql (2.9.1), and Bundler cannot continue.
Make sure that `gem install mysql -v '2.9.1'` succeeds before bundling.
我得到的错误是:

sudo gem install mysql -- —–with-mysql-config=/Applications/XAMPP/xamppfiles/bin/mysql_config
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150126-99463-2b5bwp.rb extconf.rb 
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... yes
checking for rb_thread_start_timer()... no
checking for mysql.h... yes
clang: warning: argument unused during compilation: '-L/Applications/XAMPP/xamppfiles/lib'
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling mysql.c
clang: warning: argument unused during compilation: '-L/Applications/XAMPP/xamppfiles/lib'
linking shared-object mysql/mysql_api.bundle
ld: library not found for -lmysqlclient
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql_api.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/mysql-2.9.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-14/2.0.0/mysql-2.9.1/gem_make.out
An error occurred while installing mysql (2.9.1), and Bundler cannot continue.
Make sure that `gem install mysql -v '2.9.1'` succeeds before bundling.
如果我执行
查找mysql\u config
,我会得到以下结果:

/Applications/XAMPP/xamppfiles/bin/mysql_config
/Applications/XAMPP/xamppfiles/bin/mysql_config_editor
/Applications/XAMPP/xamppfiles/man/man1/mysql_config.1
/Applications/XAMPP/xamppfiles/man/man1/mysql_config_editor.1
我已经通过了所有的帮助请求,所以我无法找到解决我的特定问题的方法

任何帮助都将不胜感激。如果你需要进一步的信息,请告诉我


谢谢

我注意到OP安装了XAMMP。下面是我在安装XAMPP后为使其正常工作所做的工作。我警告您,这并不优雅,但它确实允许您避免第二次安装mysql

# first, fake the location of the headers
sudo ln -s /Applications/XAMPP/xamppfiles /usr/local/mysql
# second, let the libraries etc show up where they are expected:
cd /usr/local/mysql/lib/mysql
for i in ../libmysql*; do sudo ln -s $i .; done
# and finally, one last hack for dynamic loading to work
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

我警告过你这有点难看:-)

这对我在MacOS X High Sierra上使用RubyGems很有效:

    gem install mysql2 -- \
        --with-mysql-config=/Applications/XAMPP/xamppfiles/bin/mysql_config \
        --with-mysql-dir=/Applications/XAMPP/xamppfiles/mysql/ \
        --with-mysql-lib=/Applications/XAMPP/xamppfiles/lib/mysql/ \
        --with-mysql-include=/Applications/XAMPP/xamppfiles/include/ \
        --no-ri --no-rdoc

我想到了这一点:

bundle config build.mysql --with-mysql-config=/Applications/XAMPP/xamppfiles/bin/mysql_config
gem install mysql2 
我的客户:

require 'mysql2'
client = Mysql2::Client.new(:host => "127.0.0.1", :username => "root")

尝试使用mysql2而不是mysql。以下是我的xampp没有
xamppfiles\include
目录的一些说明。