gpt4 book ai didi

mysql - Ruby mysql2 gem,无法在 Windows 7 上构建

转载 作者:行者123 更新时间:2023-11-29 06:16:10 25 4
gpt4 key购买 nike

我来自 OSX,其中 Ruby 90% 的时间都运行得非常完美。我已经有一段时间没有碰它了,而且现在恰好在 Windows 7 机器上工作。我正在尝试运行一个简单的 Ruby on Rails 项目,但我似乎无法通过任何数据库设置。
我想在 mysql 上运行,但是当我尝试安装 mysql2 gem(通过 bundle installgem install mysql2)时,出现以下错误:

Installing mysql2 (0.2.9) with native extensions C:/Ruby192/lib/ruby/site_ruby/1 .9.1/rubygems/installer.rb:533:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

    C:/Ruby192/bin/ruby.exe extconf.rb 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.

对于这种事情,我几乎是一个新手,所以如果有人有任何建议,请帮忙!

最佳答案

要安装和编译扩展,有时您需要依赖项的库和 header 。在这种情况下,您需要 MySQL header 和库才能正确编译。

假设您从 RubyInstaller 下载 Ruby并且还安装了Development Kit并遵循它的 installation instructions ,要成功安装 mysql2 gem,我建议您阅读我们的 Troubleshooting page 中的这个答案。 :

  1. 下载 MySQL Connector/C
  2. 提取到不带空格的路径
  3. 安装 mysql2 gem 时,提供附加选项 (gem install mysql2 -v 0.2.10 -- --with-mysql-include=... --with-mysql-lib...)

--with-mysql-include选项提供MySQL Connector/C的include目录的路径。 --with-mysql-lib 也是如此,但这次指向 lib 目录。

不要忘记将 libmysql.dll 复制到您的 Ruby bin 目录。

希望这有帮助。

关于mysql - Ruby mysql2 gem,无法在 Windows 7 上构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6367252/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com