ruby-on-rails - 用mingw编译mysql2时出现段错误

标签 ruby-on-rails ruby ruby-on-rails-4 mingw mysql2

当我尝试创建 Rails 服务器时,这就是我得到的结果。它立即运行超过 500 行代码并返回此消息。这是我的第一个 Ruby on Rails 项目。我对编码也很陌生。如果可能的话,希望得到一些帮助。谢谢你!

C:/Ruby200-x64/lib/ruby/gems/2.0.0/extensions/x64-mingw32/2.0.0/mysql2-0.3.15/my
sql2/mysql2.so: [BUG] Segmentation fault
ruby 2.0.0p451 (2014-02-24) [x64-mingw32]


    0 enumerator.so
    1 C:/Ruby200-x64/lib/ruby/2.0.0/x64-mingw32/enc/encdb.so
    2 C:/Ruby200-x64/lib/ruby/2.0.0/x64-mingw32/enc/iso_8859_1.so
    3 C:/Ruby200-x64/lib/ruby/2.0.0/x64-mingw32/enc/trans/transdb.so
    4 C:/Ruby200-x64/lib/ruby/2.0.0/x64-mingw32/rbconfig.rb
    5 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/compatibility.rb
    6 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/defaults.rb
    7 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/deprecate.rb
    8 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/errors.rb
    9 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/version.rb
   10 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/requirement.rb
   11 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/platform.rb
   12 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/basic_specification.rb
   13 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/stub_specification.rb
   14 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/util/stringio.rb
   15 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb
   16 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/exceptions.rb
   17 C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/defaults/operating_system.rb
   18 C:/Ruby200-x64/lib/ruby/2.0.0/x64-mingw32/enc/utf_16le.so
   19 C:/Ruby200-x64/lib/ruby/2.0.0/x64-mingw32/enc/trans/utf_16_32.so
   20 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb


  537 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_sup
port/core_ext/module.rb
  538 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_view/r
ecord_identifier.rb
  539 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_view/h
elpers/record_tag_helper.rb
  540 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_view/h
elpers/rendering_helper.rb
  541 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_view/h
elpers/translation_helper.rb
  542 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_view/h
elpers.rb
  543 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-rails-2.0.1/lib/sprocket
s/rails/helper.rb
  544 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/engine/co
nfiguration.rb
  545 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/applicati
on/configuration.rb
  546 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sprockets-rails-2.0.1/lib/sprocket
s/railtie.rb
  547 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/all.rb
  548 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_sup
port/string_inquirer.rb
  549 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2/version.r
b
  550 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2/error.rb

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html


This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

C:\Users\MVParker\Documents\Sites\simple_cms>

最佳答案

按照 Dave Schweisguth 的关于 ruby​​ bug 的回答,并执行 Heesob Park 评论中描述的步骤,我可以让 mysql2 gem 工作。谢谢你们分享这个。

引用 Heesob 评论:

The libmysql.lib included in the MySQL Connector/C 64 bit is not compatible with the mingw64-gcc compiler.

You need to generate mingw64 compatible libmysql.lib file.

为了创建兼容的 libmysql.lib 文件,我执行了以下步骤: (我正在运行 Win8.1 x64 和 Ruby 2.0.0p481 [x64-mingw32])

1) 下载此 zip 文件 https://structure-svm-map.googlecode.com/files/svm-map-win.zip并将其提取到 c:\tmp\svm-map

2) 从http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-6.1.3-winx64.zip下载Mysql C/Connector 6.1并将其解压到c:\tmp\mysql

3)打开CMD提示符

4) cd\tmp\svm-map\python-mingw-lib

5) gendef.exe\tmp\mysql\lib\libmysql.dll

6) 移动 libmysql.def\tmp\mysql\lib

7) cd\tmp\mysql\lib

8) \Ruby200-x64\DevKit\mingw\bin\dlltool -v --dllname libmysql.dll --def libmysql.def --output-lib libmysql.lib

9) gem install mysql2 -- --with-mysql-dir=c:\tmp\mysql

就是这样! Mysql2 gem 在 Windows 8.1 上的 Rails x64 上运行! =)

关于ruby-on-rails - 用mingw编译mysql2时出现段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23395812/

相关文章:

mysql - Rails 列带有 ":references"-- 困惑

html - 未定义 `errors'的方法:NilClass, intermediate html file

ruby - 在 Ruby 中对多个目录条目进行排序

ruby-on-rails - 使用 link_to 帮助程序在新窗口中打开链接

ruby-on-rails - 未定义方法 `to_sym' 为 nil :NilClass after migration

ruby-on-rails - 如何使 Rails caches_page 在 capistrano 部署中存活下来?

mysql - ActiveRecord 回滚多个事务

ruby-on-rails - 迁移文件的非法名称

ruby-on-rails - 未初始化的常量 ApplicationRecord

ruby-on-rails - Ruby on Rails 中的嵌套属性未保存