使用mingw编译mysql2时出现分段错误

时间:2014-04-30 18:48:00

标签: 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>

2 个答案:

答案 0 :(得分:4)

根据 Dave Schweisguth 的答案,关于ruby bug,并执行 Heesob Park 的评论所描述的步骤,我可以让mysql2 gem工作。谢谢大家分享这个。

引自Heesob评论:

  

MySQL Connector / C 64位中包含的libmysql.lib不是   与mingw64-gcc编译器兼容。

     

您需要生成与mingw64兼容的libmysql.lib文件。

要创建兼容的libmysql.lib文件,我执行了以下步骤: (我用Ruby 2.0.0p481运行Win8.1 x64 [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)move 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

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

答案 1 :(得分:1)

我用google搜索“x64-mingw32 mysql2分段错误”并发现:https://bugs.ruby-lang.org/issues/8591

看起来mysql2中有一个错误。对Ruby问题的评论提供了一种解决方法,用您的编译器重新生成libmysql.lib。请回报并告知我们是否有效。