我最近在rails和MySQL上安装了Ruby。
版本是ruby 2.1.7和MySQL Workbench 6.3 CE。
我键入了gem install mysql2 -v=0.2.6
,这发生了;
Fetching: mysql2-0.2.6.gem <100%>
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
Error: Failed to build gem native extensions.
C:/Ruby21/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... yes
checkimg for main() in -llibmysql... no
*** 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 option:
--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=.
--curdit
--ruby=C:Ruby21/bin/ruby
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-libmysqllib
--without-libmysqllib
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby21/lib/ruby/gems/2.1.0/gems/mysql2-0.2
.6 for inspection.
Results logged to C:/Ruby21/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/mys
ql2-0.2.6/gem_make.out
有人可以帮我把Ruby上的Ruby连接到MySQL吗?
答案 0 :(得分:0)
来自https://github.com/brianmario/mysql2:
Linux和其他Unix
您可能需要安装libmysqlclient-dev或mysql-devel等软件包;请参阅您的发行版的软件包指南以查找特定的软件包。我们看到的最常见问题是拥有库文件libmysqlclient.so但缺少头文件mysql.h的用户 - 请仔细检查是否安装了-dev软件包。
正确的解决方案取决于您的操作系统。由于mysql2代码部分用C语言编写,因此需要在系统上安装一些库文件才能安装它。