我试了几个星期为ruby安装mysql2所以我可以用它来潇洒。但我唯一得到的是:
gem install mysql2 --platform=ruby -- '--with-mysql-dir="/usr/include/mysql"'
Building native extensions with: '--with-mysql-dir="/usr/include/mysql"'
This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-2.2.4/bin/ruby -r ./siteconf20160203-7890-abpifj.rb extconf.rb --with-mysql-dir="/usr/include/mysql"
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Cannot find include dir(s) /usr/include/mysql/include
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/rvm/rubies/ruby-2.2.4/bin/$(RUBY_BASE_NAME)
--with-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
extconf failed, exit code 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.2.4/gems/mysql2-0.4.2 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.2.4/extensions/armv7l-linux/2.2.0/mysql2-0.4.2/gem_make.out
它是一个Raspberry Pi 2,安装了Ruby 2.2.4和RVM。
已安装libmysqlclient-dev。
mkmf.log告诉我:
have_func: checking for rb_thread_blocking_region()... -------------------- no
"gcc -o conftest -I/usr/local/rvm/rubies/ruby-2.2.4/include/ruby-2.2.0/armv7l-linux-eabihf -I/usr/local/rvm/rubies/ruby-2.2.4/include/ruby-2.2.0/ruby/backward -I/usr/local/rvm/rubies/ruby-2.2.4/include/ruby-2.2.0 -I. -D_FILE_OFFSET_BITS=64$
conftest.c: In function ‘t’:
conftest.c:13:57: error: ‘rb_thread_blocking_region’ undeclared (first use in this function)
conftest.c:13:57: note: each undeclared identifier is reported only once for each function it appears in
conftest.c:13:32: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
答案 0 :(得分:0)
您尝试安装的 mysql2 gem中有一个错误。
尝试安装以前的稳定版本0.3.X
gem install mysql2 --platform=ruby -v '~> 0.3.0'
如果这不起作用,请尝试更新 Ruby 版本。
sudo apt-get install ruby2.2
或者,如果可以,请升级
sudo apt-get install ruby2.3
答案 1 :(得分:0)
在尝试获取gem之前安装raspbian特定包。
apt-get install ruby-mysql2
ruby new projectname -dmysql
答案 2 :(得分:0)
我终于解决了以下错误:
apt-get install libmysql++-dev
答案 3 :(得分:0)
您应该
apt-get install libmariadbclient-dev