【问题标题】:on windows Mysql native extension prob in ruby on rails gem timeruby on rails gem time 中的 Windows Mysql 本机扩展问题
【发布时间】:2011-11-08 15:46:59
【问题描述】:

由于我是 ruby​​ on rails 的新手,需要专业人士的帮助,在第一次安装应用程序时,由于我在我的系统上使用 Mysql DB,我也安装了它的 gem,但是当我执行 Bundle install 时出现此错误对于一个新的项目应用程序。 以下错误发生在捆绑安装处于以下阶段时:

Installing mysql2 (0.2.13) with native extensions  

C:\Sites\proj2>捆绑安装 获取http://rubygems.org/ 的源索引 使用 rake (0.9.2) 使用抽象 (1.0.0) 使用主动支持 (3.0.9) 使用构建器 (2.1.2) 使用 i18n (0.5.0) 使用 activemodel (3.0.9) 使用 erubis (2.6.6) 使用机架 (1.2.3) 使用机架安装 (0.6.14) 使用机架测试(0.5.7) 使用 tzinfo (0.3.29) 使用动作包 (3.0.9) 使用 mime 类型 (1.16) 使用多语言 (0.3.2) 使用树顶 (1.4.10) 使用邮件 (2.2.19) 使用 actionmailer (3.0.9) 使用 arel (2.0.10) 使用活动记录 (3.0.9) 使用活动资源 (3.0.9) 使用捆绑器 (1.0.15) 使用原生扩展安装 mysql2 (0.2.13) C:/RailsInstaller/Ruby1.8.7/li b/ruby/site_ruby/1.8/rubygems/installer.rb:533:in `build_extensions': 错误: Fai 导致构建 gem 原生扩展。 (Gem::Installer::ExtensionBuildError)

        C:/RailsInstaller/Ruby1.8.7/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... no
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:/RailsInstaller/Ruby1.8.7/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


Gem files will remain installed in C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8
/gems/mysql2-0.2.13 for inspection.
Results logged to C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/mysql2-0.2.
13/ext/mysql2/gem_make.out
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/install
er.rb:486:in `each'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/install
er.rb:486:in `build_extensions'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/install
er.rb:159:in `install'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/l
ib/bundler/source.rb:101:in `install'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/l
ib/bundler/rubygems_integration.rb:78:in `preserve_paths'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/l
ib/bundler/source.rb:91:in `install'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/l
ib/bundler/installer.rb:58:in `run'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/l
ib/bundler/rubygems_integration.rb:93:in `with_build_args'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/l
ib/bundler/installer.rb:57:in `run'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/l
ib/bundler/spec_set.rb:12:in `each'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/l
ib/bundler/spec_set.rb:12:in `each'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/l
ib/bundler/installer.rb:49:in `run'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/l
ib/bundler/installer.rb:8:in `install'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/l
ib/bundler/cli.rb:222:in `install'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/l
ib/bundler/vendor/thor/task.rb:22:in `send'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/l
ib/bundler/vendor/thor/task.rb:22:in `run'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/l
ib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/l
ib/bundler/vendor/thor.rb:246:in `dispatch'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/l
ib/bundler/vendor/thor/base.rb:389:in `start'
        from C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.15/b
in/bundle:13
        from C:/RailsInstaller/Ruby1.8.7/bin/bundle:19:in `load'
        from C:/RailsInstaller/Ruby1.8.7/bin/bundle:19

C:\Sites\proj2>

【问题讨论】:

    标签: mysql ruby-on-rails windows gem


    【解决方案1】:

    mysql2 0.2.13 发布时没有适用于 Windows 的二进制文件。因此,需要编译。

    由于您使用的是 RailsInstaller,您已经拥有几乎所有的组件来解决这个问题,但我建议您阅读我发布的关于在 Windows 上编译 mysql/mysql2 gem 的博客文章:

    http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/

    然后,您可以 bundle install 并且由于 gem 已经安装,之后它应该可以工作了。

    【讨论】:

    • 非常感谢。这似乎是 64 位 Windows 7 上的 RailsInstaller 和 WAMP 的问题。您的带有连接器的博客文章完美无缺,也适用于 mysql2 gem。
    • 我有 Windows 7 32 位。当我已经通过 WAMP 拥有 mysql 服务器 5.5.16 时,安装 mysql2 适配器的命令应该是什么?
    • @noobcode 相同的命令,请参阅博客文章。只要您使用 MySQL Connector/C 而不是安装中的 MySQL 头文件/库,mysql 或 mysql2 gem 的编译是相同的。
    猜你喜欢
    • 1970-01-01
    • 2013-07-27
    • 1970-01-01
    • 2014-01-21
    • 1970-01-01
    • 1970-01-01
    • 2013-10-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多