我的职业是 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.
如果我定位 mysql_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
我已经浏览了 SO 上的所有帮助请求,但找不到针对我的特定问题的解决方案。
如有任何帮助,我们将不胜感激。如果您需要任何进一步的信息,请告诉我。
谢谢!
最佳答案
这对我使用 RubyGems 在 MacOS X High Sierra 上有效:
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
关于mysql - RoR + XAMPP + MySQL -- Gem 安装 MySQL 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28157795/