0

我正在尝试mysql2为 Ruby 2.0.0 安装 gem。

我尝试按照http://rorguide.blogspot.hk/2011/03/installing-mysql2-gem-on-ruby-192-and.html的说明进行操作,但没有成功。鉴于下面的错误消息,谁能帮我解决这个错误?

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:/xampp/Ruby200-x64ruby.exe extconf.rb
checking for rb_thread_blocking_region()... yes
checking 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 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:/xampp/Ruby200-x64ruby
        --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


Gem files will remain installed in C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.
3.6 for inspection.
Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.6/ext/mysql2/ge
m_make.out

我的红宝石是从这里下载的:

http://rubyinstaller.org/

编辑

C:\xampp\Ruby200-x64\lib\ruby\gems\2.0.0>gem install mysql2 -- '--with-mysql-lib
="c:\xampp\mysql\lib" --with-mysql-include="c:\xampp\mysql\include" --with-mysql
-config="c:/xampp/mysql/bin/mysql_config.exe"'
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-lib="c:\xampp\mysql\lib" --with-m
ysql-include="c:\xampp\mysql\include" --with-mysql-config="c:/xampp/mysql/bin/my
sql_config.exe"'
This could take a while...
ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

    C:/xampp/Ruby200-x64/bin/ruby.exe extconf.rb --with-mysql-lib="c:\xampp\mysq
l\lib" --with-mysql-include="c:\xampp\mysql\include" --with-mysql-config="c:/xam
pp/mysql/bin/mysql_config.exe"
checking for rb_thread_blocking_region()... *** 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:/xampp/Ruby200-x64/bin/ruby
C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler failed
 to generate an executable file. (RuntimeError)
You have to install development tools first.
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:516:in `try_link0'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:531:in `try_link'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:717:in `try_func'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:1001:in `block in have_
func'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:892:in `block in checki
ng_for'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block (2 levels
) in postpone'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block in postpo
ne'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:333:in `postpone'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:891:in `checking_for'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:1000:in `have_func'
        from extconf.rb:9:in `<main>'


Gem files will remain installed in C:/xampp/Ruby200-x64/lib/ruby/gems/2.0.0/gems
/mysql2-0.3.11 for inspection.
Results logged to C:/xampp/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/ex
t/mysql2/gem_make.out

C:\xampp\Ruby200-x64\lib\ruby\gems\2.0.0>gem install mysql2 -- '--with-mysql-lib
="c:/xampp/mysql/lib" --with-mysql-include="c:/xampp/mysql/include" --with-mysql
-config="c:/xampp/mysql/bin/mysql_config.exe"'
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-lib="c:/xampp/mysql/lib" --with-m
ysql-include="c:/xampp/mysql/include" --with-mysql-config="c:/xampp/mysql/bin/my
sql_config.exe"'
This could take a while...
ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

    C:/xampp/Ruby200-x64/bin/ruby.exe extconf.rb --with-mysql-lib="c:/xampp/mysq
l/lib" --with-mysql-include="c:/xampp/mysql/include" --with-mysql-config="c:/xam
pp/mysql/bin/mysql_config.exe"
checking for rb_thread_blocking_region()... *** 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:/xampp/Ruby200-x64/bin/ruby
C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler failed
 to generate an executable file. (RuntimeError)
You have to install development tools first.
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:516:in `try_link0'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:531:in `try_link'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:717:in `try_func'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:1001:in `block in have_
func'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:892:in `block in checki
ng_for'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block (2 levels
) in postpone'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block in postpo
ne'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:333:in `postpone'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:891:in `checking_for'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:1000:in `have_func'
        from extconf.rb:9:in `<main>'


Gem files will remain installed in C:/xampp/Ruby200-x64/lib/ruby/gems/2.0.0/gems
/mysql2-0.3.11 for inspection.
Results logged to C:/xampp/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/ex
t/mysql2/gem_make.out

C:\xampp\Ruby200-x64\lib\ruby\gems\2.0.0>gem install mysql -- '--with-mysql-lib=
"c:/xampp/mysql/lib" --with-mysql-include="c:/xampp/mysql/include" --with-mysql-
config="c:/xampp/mysql/bin/mysql_config.exe"'
Fetching: mysql-2.9.1.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-lib="c:/xampp/mysql/lib" --with-m
ysql-include="c:/xampp/mysql/include" --with-mysql-config="c:/xampp/mysql/bin/my
sql_config.exe"'
This could take a while...
ERROR:  Error installing mysql:
        ERROR: Failed to build gem native extension.

    C:/xampp/Ruby200-x64/bin/ruby.exe extconf.rb --with-mysql-lib="c:/xampp/mysq
l/lib" --with-mysql-include="c:/xampp/mysql/include" --with-mysql-config="c:/xam
pp/mysql/bin/mysql_config.exe"
checking for main() in -llibmysql... *** 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:/xampp/Ruby200-x64/bin/ruby
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include=${mysql-dir}/include
        --with-mysql-lib=${mysql-dir}/
        --with-libmysqllib
        --without-libmysqllib
C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler failed
 to generate an executable file. (RuntimeError)
You have to install development tools first.
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:516:in `try_link0'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:531:in `try_link'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:717:in `try_func'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:947:in `block in have_l
ibrary'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:892:in `block in checki
ng_for'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block (2 levels
) in postpone'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block in postpo
ne'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:333:in `postpone'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:891:in `checking_for'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:942:in `have_library'
        from extconf.rb:27:in `<main>'


Gem files will remain installed in C:/xampp/Ruby200-x64/lib/ruby/gems/2.0.0/gems
/mysql-2.9.1 for inspection.
Results logged to C:/xampp/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql-2.9.1/ext/
mysql_api/gem_make.out

C:\xampp\Ruby200-x64\lib\ruby\gems\2.0.0>gem install mysql -- '--with-mysql-lib=
"c:/xampp/mysql/lib" --with-mysql-include="c:/xampp/mysql/include" --with-mysql-
config="c:/xampp/mysql/bin/mysql_config"'
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-lib="c:/xampp/mysql/lib" --with-m
ysql-include="c:/xampp/mysql/include" --with-mysql-config="c:/xampp/mysql/bin/my
sql_config"'
This could take a while...
ERROR:  Error installing mysql:
        ERROR: Failed to build gem native extension.

    C:/xampp/Ruby200-x64/bin/ruby.exe extconf.rb --with-mysql-lib="c:/xampp/mysq
l/lib" --with-mysql-include="c:/xampp/mysql/include" --with-mysql-config="c:/xam
pp/mysql/bin/mysql_config"
checking for main() in -llibmysql... *** 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:/xampp/Ruby200-x64/bin/ruby
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include=${mysql-dir}/include
        --with-mysql-lib=${mysql-dir}/
        --with-libmysqllib
        --without-libmysqllib
C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler failed
 to generate an executable file. (RuntimeError)
You have to install development tools first.
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:516:in `try_link0'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:531:in `try_link'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:717:in `try_func'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:947:in `block in have_l
ibrary'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:892:in `block in checki
ng_for'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block (2 levels
) in postpone'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:337:in `block in postpo
ne'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:307:in `open'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:333:in `postpone'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:891:in `checking_for'
        from C:/xampp/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:942:in `have_library'
        from extconf.rb:27:in `<main>'


Gem files will remain installed in C:/xampp/Ruby200-x64/lib/ruby/gems/2.0.0/gems
/mysql-2.9.1 for inspection.
Results logged to C:/xampp/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql-2.9.1/ext/
mysql_api/gem_make.out

C:\xampp\Ruby200-x64\lib\ruby\gems\2.0.0>
4

4 回答 4

1
checking for main() in -llibmysql... no

你缺少 libmysql-headers。

编辑:是重复的:在 Windows 上安装 mysql-2.9.0 gem 由于缺少 libmysql 而失败

于 2013-04-30T08:05:02.020 回答
0

llibmysql 错误意味着 ruby​​ 看不到 libmysql.dll。我刚才得到了错误,所以我将 libmySQL.dll 复制到 $mysqldir/lib 并得到另一个错误

checking for main() in -llibmysql... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing.  please check your installation of mysql and try again.

所以,现在 ruby​​ 可以看到 libmysql.dll,但现在它需要 mysql 文件。我再次启动 mysql 安装程序并选择我需要包含文件。2 分钟 - 我得到了包含目录。再次启动gem install mysql2....并得到1 gem installed.

于 2013-08-16T20:01:58.813 回答
0

如果像我一样,您有一些同事正在使用 Windows(在我的情况下为 Windows 7)从事 Rails 项目。为了安装 gem “mysql2”,您需要在命令行中指定使用库的路径。

先决条件:已安装 MYSQL。

要运行的命令行(将路径替换为您的安装路径)

 gem install mysql2 — ‘–with-mysql-lib=”c:\Program Files\MySQL\MySQL Server 5.6\lib” –with-mysql-include=”c:\Program Files\MySQL\MySQL Server 5.6\include”‘
于 2014-08-04T17:47:34.693 回答
0

你的错误清楚地表明它是关于你的Devkit 所以你可以从

http://rubyinstaller.org/downloads

并按照以下步骤操作

https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

这将解决您的问题

于 2013-04-30T13:22:00.690 回答