我在Ruby上安装mysql2 gem时遇到了一些问题,我已经尝试了很多指南,但似乎没有任何工作......当我尝试安装它时,这是错误,没有任何额外的命令
C:\Users\Julián>gem install mysql2 --no-rdoc --no-ri
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/Ruby200-x64/bin/ruby.exe extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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 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=C:/Ruby200-x64/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}/
--with-mysql-config
--without-mysql-config
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/
--with-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mygcclib
--without-mygcclib
--with-mysqlclientlib
--without-mysqlclientlib
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql
2-0.3.16 for inspection.
Results logged to C:/Ruby200-x64/lib/ruby/gems/2.0.0/extensions/x64-mingw32/2.0.
0/mysql2-0.3.16/gem_make.out
我真的很难过,我试图找到一个解决方案,但找不到任何东西。我尝试安装MySQL连接器并设置with-mysql-lib命令。请帮忙!
答案 0 :(得分:2)
由于您似乎在使用Windows,因此您需要考虑必须安装MYSQL C-Connector
标头文件才能使其正常工作
-
您需要使用以下步骤:
- 安装
MYSQL C-Connector
个文件(路径中没有任何空格)- 再次安装MYSQL2 gem(使用正确的路径引用)
- 将
醇>lbmysql.dll
复制到您的ruby/bin
文件夹
首先,您需要下载MYSQL C-Connector文件:
是32位C连接器
一旦将此安装到没有空格的路径中,您就可以再次使用mysql2
安装命令,配置选项:
gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\mysql-connector-path"'
然后,您可以将libmysql.dll
从mysql
文件转移到ruby/bin
目录:
答案 1 :(得分:0)
在终端中..首先执行'定位mysql_config '然后将以下命令中的路径替换为该文件的位置。
gem install mysql2 --no-rdoc --no-ri --with-mysql-config = 路径