Segmentation fault when compiling mysql2 with mingw

混江龙づ霸主 提交于 2020-01-02 09:31:34

问题


When I try to create a Rails server this is what I get. It instantly runs over 500+ lines of code and comes back with this message. This is my first Ruby on Rails project. I am pretty new to coding as well. Would love some help if possible. Thank you!

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>

回答1:


I googled "x64-mingw32 mysql2 Segmentation fault" and found this: https://bugs.ruby-lang.org/issues/8591

Looks like there is a bug in mysql2. A comment on the Ruby issue gives a workaround, regenerating libmysql.lib with your compiler. Please report back and let us know if it works.




回答2:


Following the answer from Dave Schweisguth, about the ruby bug, and doing the steps described by Heesob Park's comment, I could get mysql2 gem to work. Thank you guys for sharing this.

Quote from Heesob comment:

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.

To create an compatible libmysql.lib file, I did the following steps: (I'm running Win8.1 x64 with Ruby 2.0.0p481 [x64-mingw32])

1) Downloaded this zip file https://structure-svm-map.googlecode.com/files/svm-map-win.zip and extracted it to a c:\tmp\svm-map

2) Downloaded Mysql C/Connector 6.1 from http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-6.1.3-winx64.zip and extracted it to c:\tmp\mysql

3) Open CMD Prompt

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

That´s it! Mysql2 gem running on Rails x64 on Windows 8.1! =)



来源:https://stackoverflow.com/questions/23395812/segmentation-fault-when-compiling-mysql2-with-mingw

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!