无法安装mysql2 gem [英] Cannot install mysql2 gem

查看:112
本文介绍了无法安装mysql2 gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在我的Windows7 x64系统中安装mysql2 gem。我尝试使用32位和64位版本的MySQL服务器,但没有任何进一步的帮助。



我安装了Ruby 1.8,开发工具包和Rails平台。我甚至安装了minGW以允许C ++ / C编译。 MySQL服务器安装在默认位置。



运行命令时:

  C:\ Users \ Arne> gem install mysql2  -  --with-mysql-include =C:\ Program Files(x86)\MySQL\MySQL Server 5.1\include--with -mysql-lib =C:\ Program Files(x86)\MySQL\MySQL Server 5.1\lib\

我从控制台收到以下输出:

 临时增强PATH以包括DevKit ... 
构建本地扩展。这可能需要一段时间...
*** extconf.rb失败***
由于某些原因无法创建Makefile,可能缺少
必需的库和/或头文件。查看mkmf.log文件以获取更多
的详细信息。您可能需要配置选项。

提供的配置选项:
--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:/ Ruby / bin / ruby​​
--with-mysql-dir
--without-mysql-dir
- -with-mysql-include = $ {mysql-dir} / include
--with-mysql-lib = $ {mysql-dir} / lib
--with-libmysqllib
- without-libmysqllib
错误:安装mysql2时出错:
错误:无法构建gem原生扩展。

C:/Ruby/bin/ruby.exe extconf.rb --with-mysql-include = C:\程序文件(x
86)\MySQL\MySQL Server 5.1 \ include --with-mysql-lib = C:\程序文件(x86)\MySQL
\ MySQL服务器5.1 \lib
检查rb_thread_blocking_region()...否
在-llibmysql中检查main()... no


Gem文件将保持安装在C:/Ruby/lib/ruby/gems/1.8/gems/mysql2 -0.3.2 f
或检查
记录到C的结果:/Ruby/lib/ruby/gems/1.8/gems/mysql2-0.3.2/ext/mysql2/gem_mak
e .out

根据Rubygems,我的环境输出为:

  C:\ Users \\ Arne> gem env 
RubyGems环境:
- RUBYGEMS版本:1.7.2
- RUBY版本:1.8.7(2011-02-18 patchlevel 334)[i386-mingw32]
- 安装目录:C:/Ruby/lib/ruby/gems/1.8
- RUBY EXECUTABLE:C:/ Ruby / bin / ruby​​.exe
- EXECUTABLE DIRECTORY:C:/ Ruby / bin
- R UBYGEMS PLATFORMS:
- ruby​​
- x86-mingw32
- 创业板路径:
- C:/Ruby/lib/ruby/gems/1.8
- C:/ Users / Arne / .gem / ruby​​ / 1.8
- GEM配置:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- 远程来源:
- http://rubygems.org/

系统中还安装了以下gem:

  C:\ Users \ Arne> gem list  - 本地

***本地GEMS ***

抽象(1.0.0)
actionmailer(3.0.7)
actionpack(3.0.7 )
activemodel(3.0.7)
activerecord(3.0.7)
activeresource(3.0.7)
activesupport(3.0.7)
arel(2.0.9) )
builder(3.0.0,2.1.2)
bundler(1.0.12)
erubis(2.7.0,2.6.6)
fastthread(1.0.7)
i18n(0.5.0)
mail(2.3.0,2.2.18)
mime-types(1.16)
mysql(2.8.1 x86-mingw32)
(0.3.1)
机架(1.2.2)
机架安装(0.7.2,0.6.14)
机架测试(0.5.7)
导轨3.0.7)
railties(3.0.7)
rake(0.8.7)
rdoc(3.5.3,2.5.11)
rdoc-data(2.5.3)
ruby​​gems-update(1.7.2)
thor(0.14.6)
树梢(1.4.9)
tzinfo(0.3.27,0.3.26)

我这样做不知道什么是缺失或错误,但脚本指向的输出文件包含以下数据:

mkmf.log:

  have_func:检查rb_thread_blocking_region()... -------------------- no 

gcc -o conftest -I。 -IC:/Ruby/lib/ruby/1.8/i386-mingw32 -I。 -g -O2 -DFD_SETSIZE = 256 conftest.c -L。 -LC:/ Ruby / lib -L。 -lmsvcrt-ruby18-static -lshell32 -lws2_32
conftest.c:函数't':
conftest.c:7:53:error:'rb_thread_blocking_region'未声明(在此函数中首次使用)
conftest.c:7:53:注意:每个未声明的标识符仅对于它出现在
中的每个函数报告一次b检查的程序是:
/ * begin * /
1: #include< ws2tcpip.h>
2:#include< winsock2.h>
3:#include< windows.h>
4:
5:/ * (*)(*)()()()()*()* * ))rb_thread_blocking_region; return 0;}
/ * end * /

gcc -o conftest -I。 -IC:/Ruby/lib/ruby/1.8/i386-mingw32 -I。 -g -O2 -DFD_SETSIZE = 256 conftest.c -L。 -LC:/ Ruby / lib -L。 -lmsvcrt-ruby18-static -lshell32 -lws2_32
C:\ Users \Arne\AppData\Local\Temp\ccCicaNu.o:在函数`t'中:
C: \Ruby\lib\ruby\gems\1.8\gems\mysql2-0.3.2\ext\mysql2/conftest.c:3:对`rb_thread_blocking_region'的未定义引用
collect2: ld返回1退出状态
检查程序是:
/ * begin * /
1:/ * top * /
2:int main(){return 0;}
3:int t(){rb_thread_blocking_region(); return 0;}
/ * end * /

---------------- ----

have_library:在-llibmysql中检查main()... -------------------- no

gcc -o conftest -I。 -IC:/Ruby/lib/ruby/1.8/i386-mingw32 -I。 -IC:\程序-g -O2 -DFD_SETSIZE = 256 conftest.c -L。 -LC:/ Ruby / lib -LC:\ Program-L。 -lmsvcrt-ruby18-static -llibmysql -lshell32 -lws2_32
c:/ mingw / bin /../ lib / gcc / mingw32 / 4.5.2 /../../../../ mingw32 / bin / ld.exe:找不到-llibmysql
collect2:ld返回1退出状态
检查程序是:
/ * begin * /
1:#include 2:#include< winsock2.h>
3:#include< windows.h>
4:
5:/ * top * /
6:int main(){return 0;}
7:int t(){void((* volatile p)()); p =(void((*)()))main; return 0 ;}
/ * end * /

gcc -o conftest -I。 -IC:/Ruby/lib/ruby/1.8/i386-mingw32 -I。 -IC:\程序-g -O2 -DFD_SETSIZE = 256 conftest.c -L。 -LC:/ Ruby / lib -LC:\ Program-L。 -lmsvcrt-ruby18-static -llibmysql -lshell32 -lws2_32
c:/ mingw / bin /../ lib / gcc / mingw32 / 4.5.2 /../../../../ mingw32 / bin / ld.exe:找不到-llibmysql
collect2:ld返回1退出状态
检查程序为:
/ * begin * /
1:/ * top * /
2:int main(){return 0;}
3:int t(){main(); return 0;}
/ * end * /

--------------------

gem_make .out:

  C:/Ruby/bin/ruby.exe extconf.rb --with-mysql-include = C: \ Program Files(x86)\MySQL\MySQL Server 5.1\include --with-mysql-lib = C:\ Program Files(x86)\MySQL\MySQL Server 5.1\lib
检查rb_thread_blocking_region()... no
检查main()in -llibmysql ... no

我希望有人能够指出我做错了什么,或者我的开发系统上真正缺少的东西,以便正确安装并正常工作。

>解决方案

I fi nally解决了这个问题:
$ b


  1. 下载并安装了MySQL 64位版本5.5
  2. 下载了zip压缩包32位版本5.5。

  3. 将32位include和lib文件夹提取到 C:\MySQL

  4. 安装Ruby 1.9.2。
  5. 安装Ruby Devkit。
  6. 安装宝石:


    1. gem install mysql

    2. gem install mysql2 - --with-mysql- lib = C:\MySQL\lib --with-mysql-include = C:\MySQL\include

    3. gem install rails

    4. gem install fastthread

    5. gem install haml


现在作为一种魅力工作。看来MySQL gem在处理64位时会遇到问题。


I'm unable to install the mysql2 gem in my Windows7 x64 system. I tried using both the 32-bit and 64-bit versions of MySQL server but none got me any further.

I installed Ruby 1.8, the development kit and and the Rails platform. I even installed minGW to allow C++/C compilation of things. MySQL Server was installed in the default location.

When running the command:

C:\Users\Arne>gem install mysql2 -- --with-mysql-include="C:\Program Files (x86)\MySQL\MySQL Server 5.1\include" --with-mysql-lib="C:\Program Files (x86)\MySQL\MySQL Server 5.1\lib\"

I receive the following output from the console:

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
*** 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:/Ruby/bin/ruby
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include=${mysql-dir}/include
        --with-mysql-lib=${mysql-dir}/lib
        --with-libmysqllib
        --without-libmysqllib
ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

        C:/Ruby/bin/ruby.exe extconf.rb --with-mysql-include=C:\Program Files (x
86)\MySQL\MySQL Server 5.1\include --with-mysql-lib=C:\Program Files (x86)\MySQL
\MySQL Server 5.1\lib"
checking for rb_thread_blocking_region()... no
checking for main() in -llibmysql... no


Gem files will remain installed in C:/Ruby/lib/ruby/gems/1.8/gems/mysql2-0.3.2 f
or inspection.
Results logged to C:/Ruby/lib/ruby/gems/1.8/gems/mysql2-0.3.2/ext/mysql2/gem_mak
e.out

The output of my environment according to Rubygems is:

C:\Users\Arne>gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.7.2
  - RUBY VERSION: 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: C:/Ruby/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/Ruby/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - C:/Ruby/lib/ruby/gems/1.8
     - C:/Users/Arne/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

The following gems have been installed on the system as well:

C:\Users\Arne>gem list --local

*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (3.0.7)
actionpack (3.0.7)
activemodel (3.0.7)
activerecord (3.0.7)
activeresource (3.0.7)
activesupport (3.0.7)
arel (2.0.9)
builder (3.0.0, 2.1.2)
bundler (1.0.12)
erubis (2.7.0, 2.6.6)
fastthread (1.0.7)
i18n (0.5.0)
mail (2.3.0, 2.2.18)
mime-types (1.16)
mysql (2.8.1 x86-mingw32)
polyglot (0.3.1)
rack (1.2.2)
rack-mount (0.7.2, 0.6.14)
rack-test (0.5.7)
rails (3.0.7)
railties (3.0.7)
rake (0.8.7)
rdoc (3.5.3, 2.5.11)
rdoc-data (2.5.3)
rubygems-update (1.7.2)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.27, 0.3.26)

I don't know what's missing or wrong, but the output files pointed to by the script contain the following data:

mkmf.log:

have_func: checking for rb_thread_blocking_region()... -------------------- no

"gcc -o conftest -I. -IC:/Ruby/lib/ruby/1.8/i386-mingw32 -I.    -g -O2 -DFD_SETSIZE=256    conftest.c  -L. -LC:/Ruby/lib -L.      -lmsvcrt-ruby18-static  -lshell32 -lws2_32  "
conftest.c: In function 't':
conftest.c:7:53: error: 'rb_thread_blocking_region' undeclared (first use in this function)
conftest.c:7:53: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
1: #include <ws2tcpip.h>
2: #include <winsock2.h>
3: #include <windows.h>
4: 
5: /*top*/
6: int main() { return 0; }
7: int t() { void ((*volatile p)()); p = (void ((*)()))rb_thread_blocking_region; return 0; }
/* end */

"gcc -o conftest -I. -IC:/Ruby/lib/ruby/1.8/i386-mingw32 -I.    -g -O2 -DFD_SETSIZE=256    conftest.c  -L. -LC:/Ruby/lib -L.      -lmsvcrt-ruby18-static  -lshell32 -lws2_32  "
C:\Users\Arne\AppData\Local\Temp\ccCicaNu.o: In function `t':
C:\Ruby\lib\ruby\gems\1.8\gems\mysql2-0.3.2\ext\mysql2/conftest.c:3: undefined reference to `rb_thread_blocking_region'
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { rb_thread_blocking_region(); return 0; }
/* end */

--------------------

have_library: checking for main() in -llibmysql... -------------------- no

"gcc -o conftest -I. -IC:/Ruby/lib/ruby/1.8/i386-mingw32 -I. -IC:\Program    -g -O2 -DFD_SETSIZE=256    conftest.c  -L. -LC:/Ruby/lib -LC:\Program -L.      -lmsvcrt-ruby18-static -llibmysql  -lshell32 -lws2_32  "
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -llibmysql
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: #include <ws2tcpip.h>
2: #include <winsock2.h>
3: #include <windows.h>
4: 
5: /*top*/
6: int main() { return 0; }
7: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
/* end */

"gcc -o conftest -I. -IC:/Ruby/lib/ruby/1.8/i386-mingw32 -I. -IC:\Program    -g -O2 -DFD_SETSIZE=256    conftest.c  -L. -LC:/Ruby/lib -LC:\Program -L.      -lmsvcrt-ruby18-static -llibmysql  -lshell32 -lws2_32  "
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -llibmysql
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { main(); return 0; }
/* end */

--------------------

gem_make.out:

C:/Ruby/bin/ruby.exe extconf.rb --with-mysql-include=C:\Program Files (x86)\MySQL\MySQL Server 5.1\include --with-mysql-lib=C:\Program Files (x86)\MySQL\MySQL Server 5.1\lib"
checking for rb_thread_blocking_region()... no
checking for main() in -llibmysql... no

I hope someone can point what I'm doing wrong, or what is actually missing on my development system to get this gem properly installed and working.

解决方案

I finally solved it:

  1. Downloaded and installed MySQL 64bit version 5.5
  2. Downloaded the zip archive for the 32bit version 5.5.
  3. Extracted the 32-bit include and lib folders to C:\MySQL.
  4. Installed Ruby 1.9.2.
  5. Installed the Ruby Devkit.
  6. Installed the gems:

    1. gem install mysql
    2. gem install mysql2 -- --with-mysql-lib=C:\MySQL\lib --with-mysql-include=C:\MySQL\include
    3. gem install rails
    4. gem install fastthread
    5. gem install haml

It's working as a charm now. It seems the MySQL gem has issues finding the data when dealing with 64-bit.

这篇关于无法安装mysql2 gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆