简体   繁体   English

mysql2 gem无法在Windows 7上安装:无法生成gem本机扩展

[英]mysql2 gem failing to install on Windows 7: failed to build gem native extension

we tried suggestions from this SO post about correcting installation errors with the mysql2 gem, but our problems persisted. 我们尝试了这篇SO帖子中有关使用mysql2 gem纠正安装错误的建议,但问题仍然存在。 we also looked at other SO posts like this one , but none helped. 我们还查看了其他类似这样的 SO帖子,但是没有一个帮助。

we're on rails 3.2.12 on windows 7. 我们在Windows 7上处于3.2.12的轨道上。

libmysql.dll is installed in C:\\RailsInstaller\\Ruby1.9.3\\bin , though this was installed in March 2013. libmysql.dll安装在C:\\RailsInstaller\\Ruby1.9.3\\bin ,尽管已于2013年3月安装。

error: 错误:

Using mongo_mapper (0.12.0)
Installing mysql2 (0.3.15)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb
checking for ruby/thread.h... no
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:/RailsInstaller/Ruby1.9.3/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-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}/lib
        --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


Gem files will remain installed in C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.15
Results logged to C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.15/ext/mysql2/gem_m
An error occurred while installing mysql2 (0.3.15), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.15'` succeeds before bundling.

Wrote an update on how to do this (after we've had to do it a lot): 编写了有关如何执行此操作的更新 (在我们不得不做很多之后):

  • Download MYSQL C-Connector Library (32-bit only) 下载MYSQL C连接器库 (仅32位)
  • Unzip to "no-spaces" path (EG C:/mysql-connector ) 解压缩到“无空格”路径(例如,EG C:/mysql-connector
  • Install the gem using relative paths: 使用相对路径安装gem:
 gem install mysql2 —platform=ruby — '—with-mysql-dir=”C:\\mysql-connector-path”' 
  • Add the DLL to your Ruby/bin folder (you've done already) 将DLL添加到您的Ruby / bin文件夹(已经完成)

Reason 原因

The reason this fails is because Win 7 does not have MYSQL libraries installed, meaning Ruby cannot reference the files it needs to install the gem 失败的原因是因为Win 7没有安装MYSQL库,这意味着Ruby无法引用安装gem所需的文件。

You need to install the correct files (which can be removed later on). 您需要安装正确的文件(以后可以将其删除)。 It seems you've installed the wrong ones, which will probably be the reason why the gem fails to install 看来您安装的是错误的,这可能是gem无法安装的原因

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 安装mysql2 gem时出错:无法构建gem原生扩展 - Error installing mysql2 gem: Failed to build gem native extension 无法在 Mysql Docker 容器中安装 mysql2 gem:无法构建 gem 本机扩展 - Cannot install mysql2 gem inside Mysql Docker container: Failed to build gem native extension 安装 mysql2 时出错:无法构建 gem 原生扩展 - Error installing mysql2: Failed to build gem native extension 错误:无法构建 gem 本机扩展(rails 3.2.3 上的 mysql2) - ERROR: Failed to build gem native extension (mysql2 on rails 3.2.3) 错误:无法构建 gem 原生扩展 - 安装 mysql2 时出错 - ERROR: Failed to build gem native extension - Error installing mysql2 gem install mysql:无法构建gem原生扩展(Mac Lion) - gem install mysql: Failed to build gem native extension (Mac Lion) 安装mysql的Rails - 安装mysql2时出错:错误:无法构建gem原生扩展 - Rails installing mysql - Error installing mysql2: ERROR: Failed to build gem native extension MySQL 安装:错误:无法构建 gem 原生扩展 - MySQL Install: ERROR: Failed to build gem native extension 错误:安装mysql2时出错:错误:无法构建gem原生扩展。 在Mac 10.12上 - ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. on Mac 10.12 错误:安装mysql2时出错:错误:无法构建gem原生扩展 - ERROR: Error installing mysql2: ERROR: Failed to build gem native extension
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM