Re: [RubyInstaller] Devkit won't build native extensions for Mysql or Mysql2 (Ruby 2.0-64, Devkit 64)

3,321 views
Skip to first unread message

Luis Lavena

unread,
Mar 21, 2013, 9:38:15 AM3/21/13
to rubyin...@googlegroups.com
Hello Craig, welcome,

On Thu, Mar 21, 2013 at 4:21 AM, Craig Walsh <cricha...@gmail.com> wrote:
> "Could not create Makefile due to some reason, probably lack of necessary
> libraries and/or headers."
>
> Was able to install json gem without errors.
>
> Worth a try before re-installing previous version.
>

Just to confirm:

Ruby 2.0.0, x64 version + mingw64-64-4.7.2 DevKit, correct?

Installed without issues json using "gem install json --platform=ruby", correct?

For MySQL, did you obtain headers and libraries for the 64bits version?

MySQL extension differs from JSON in that it requires external headers
and libraries.

For example, here is an article about compiling mysql gem against
MySQL Connector/C:

http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/

The instructions works for both mysql and mysql2 gem.

In your case, you will need to obtain MySQL Connector/C 64bits version
and use that instead.

Can you paste the output of "gem install mysql --platform=ruby --
--with-mysql-dir=C:/mysql-connector-64"

(replace mysql-connector-64 with the directory where you extracted
MySQL Connector/C for 64bits)

Regards,
--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Craig Walsh

unread,
Mar 21, 2013, 11:37:11 AM3/21/13
to rubyin...@googlegroups.com
It worked, thanks. Still working on other issues with bundle install.

Craig Walsh

unread,
Mar 21, 2013, 12:23:39 PM3/21/13
to rubyin...@googlegroups.com
Here's what i used: gem install mysql --platform=ruby -- --with-mysql-include=C:\mysql-connector-c-noinstall-6.0.2-winx64\include --with-mysql-lib=C:\mysql-connector-c-noinstall-6.0.2-winx64\lib

Works for mysql2 also.

Craig Walsh

unread,
Mar 21, 2013, 1:08:38 PM3/21/13
to rubyin...@googlegroups.com


On Thursday, March 21, 2013 10:23:39 AM UTC-6, Craig Walsh wrote:
Here's what i used: gem install mysql --platform=ruby -- --with-mysql-include=C:\mysql-connector-c-noinstall-6.0.2-winx64\include --with-mysql-lib=C:\mysql-connector-c-noinstall-6.0.2-winx64\lib

Works for mysql2 also.

Here's the rake error I'm getting:
 [rake --tasks] C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/lib/mysql2/mysql2.so: [BUG] Segmentation fault
ruby 2.0.0p0 (2013-02-24) [x64-mingw32]
-- Control frame information -----------------------------------------------
c:0026 p:-8826948 s:0087 e:000086 TOP    [FINISH]
c:0025 p:---- s:0085 e:000084 CFUNC  :require

....[I've deleted a large portion of redundant errors]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

Luis Lavena

unread,
Mar 21, 2013, 1:57:52 PM3/21/13
to rubyin...@googlegroups.com
On Thu, Mar 21, 2013 at 2:08 PM, Craig Walsh <cricha...@gmail.com> wrote:
>
>
> On Thursday, March 21, 2013 10:23:39 AM UTC-6, Craig Walsh wrote:
>>
>> Here's what i used: gem install mysql --platform=ruby --
>> --with-mysql-include=C:\mysql-connector-c-noinstall-6.0.2-winx64\include
>> --with-mysql-lib=C:\mysql-connector-c-noinstall-6.0.2-winx64\lib
>>
>> Works for mysql2 also.
>
>
> Here's the rake error I'm getting:
> [rake --tasks]
> C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/lib/mysql2/mysql2.so:
> [BUG] Segmentation fault
> ruby 2.0.0p0 (2013-02-24) [x64-mingw32]
> -- Control frame information -----------------------------------------------
> c:0026 p:-8826948 s:0087 e:000086 TOP [FINISH]
> c:0025 p:---- s:0085 e:000084 CFUNC :require
>
> ....[I've deleted a large portion of redundant errors]
>

Can you tell me if libmysql.dll is the ONLY libmysql.dll in the path?

You can do "where libmysql.dll" and should tell you the locations.

You can use "Dependency Walker" to determine the architecture of the
DLL (if is 32 or 64bits)

I'm not sure if MySQL Connector/C uses msvcrt.dll, most likely
requires a newer version of it, which can be a problem.

Craig Walsh

unread,
Mar 22, 2013, 12:14:58 PM3/22/13
to rubyin...@googlegroups.com
I've switched back to 1.9.3, but I'll re-install 2.0 over the weekend and let you know . Ruby 2.0 was a clean install (everything removed prior to). My path to the libmysql.dll has always been ruby/bin and copied the dll to that directory from the appropriate C connector directory. Ran "where" on current config and confirmed the only location.

Luis Lavena

unread,
Mar 22, 2013, 1:48:13 PM3/22/13
to rubyin...@googlegroups.com
On Fri, Mar 22, 2013 at 1:14 PM, Craig Walsh <cricha...@gmail.com> wrote:
> I've switched back to 1.9.3, but I'll re-install 2.0 over the weekend and
> let you know . Ruby 2.0 was a clean install (everything removed prior to).
> My path to the libmysql.dll has always been ruby/bin and copied the dll to
> that directory from the appropriate C connector directory. Ran "where" on
> current config and confirmed the only location.
>

This is most likely what I feared: the compiled version of
libmysql.dll might be linking to a different CRT and that might be
causing the segfaults.

I'm going to check over the weekend and see what is going on.

Luis Lavena

unread,
Jul 3, 2013, 6:15:58 AM7/3/13
to rubyin...@googlegroups.com
Hello Chris,

Sorry for the late response, but this come to my attention as the possible solution to the issue:


Also reported here:





On Wed, May 29, 2013 at 2:05 PM, Chris Mapes <m...@chrismapes.com> wrote:
Let us know what you find Luis, I'm experiencing the same issues as Craig. Unfortunately I've dumped over 6 hours into trying to get a working Windows 7 x64 + Ruby 2.0.0 + Mysql2 installation to work and it's just not happening. I'd love to see a fix.

--
You received this message because you are subscribed to the Google Groups "RubyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyinstalle...@googlegroups.com.
To post to this group, send email to rubyin...@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyinstaller?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Message has been deleted

Luis Lavena

unread,
Jul 7, 2013, 1:54:52 PM7/7/13
to rubyin...@googlegroups.com
Hello Badal,

On Fri, Jul 5, 2013 at 9:47 AM, Badal <mic...@demazure.com> wrote:

Dear Luis,

You cite this as a path to the solution
It requires the use of dlltool.
Do you know where to find a dlltool.exe compiled by mingw64 (same level as the 64 bits devkit) ?


dlltool is part of the DevKit, you simply need to enable MinGW in the PATH by running "devkitvars.bat"

C:\Users\Luis>C:\Users\Luis\Tools\DevKit\mingw64-64-4.7.2\devkitvars.bat
Adding the DevKit to PATH...

C:\Users\Luis>dlltool --version
GNU dlltool (rubenvb-4.7.2-release) 2.23.51.20120920
Copyright 2012 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

===

gendef might require compilation from source:


I pre-compiled it for you:


You can use that to follow the instructions provided.

I'm looking now into better ways to offer this as a solution and will follow up later.

Thank you.
-- 

Badal

unread,
Jul 8, 2013, 4:15:58 AM7/8/13
to rubyin...@googlegroups.com


Le dimanche 7 juillet 2013 19:54:52 UTC+2, Luis Lavena a écrit :
Hello Badal,

dlltool is part of the DevKit, you simply need to enable MinGW in the PATH by running "devkitvars.bat"

==> Thanks. I should have looked there. Shame on me !


gendef might require compilation from source:


I pre-compiled it for you:


==> Thanks a lot again.

_md (badal)

Badal

unread,
Jul 8, 2013, 4:49:16 AM7/8/13
to rubyin...@googlegroups.com

FWIW : there is a patched connector available, thanks to 'mgoggin'. From his comment (URL below)

https://groups.google.com/forum/#!topic/rubyinstaller/uTNffOt6Yqo

" here's a pre-patched ZIP of the C Connector 6.0.2 64-bit: https://copy.com/CHZ4eT4us6f1 "

It works !

C:\Ruby200-x64\bin>gem install mysql2 --platform=ruby -- --with_opt-dir=C:\mysql-connector-c-noinstall-6.0.2-winx64

Fetching: mysql2-0.3.11.gem (100%)

Temporarily enhancing PATH to include DevKit...

Building native extensions with: '--with_opt-dir=C:\mysql-connector-c-noinstall-6.0.2-winx64'

This could take a while...

Successfully installed mysql2-0.3.11

1 gem installed


mc2

unread,
Aug 11, 2013, 3:52:47 PM8/11/13
to rubyin...@googlegroups.com
the command: gem install mysql2 --platform=ruby -- --with_opt-dir=C:\mysql-connector-c-noinstall-6.0.2-winx64
did not work for me, Error:
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
*** 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.

but I now realize didn't run it from C:\Ruby200-x64\bin I don't think that should matter. 

in a default command prompt, I had success with:
gem install --platform=ruby mysql2 -- --with-mysql-lib=C:\mysql-connector-c-noinstall-6.0.2-winx64\lib --with-mysql-include=C:\mysql-connector-c-noinstall-6.0.2-winx64\include

And after copying libmysql.dll to C:\Ruby200-x64\bin, creating the development db, setting the right connection string in \config\database.yml, rails server finally works.

Thanks for all help, and not to complain unduly, but using the pre-patched ZIP is a security hole for a production server. 

If someone could create some short instructions for making gendef.exe from http://sourceforge.net/projects/mingw-w64/, perhaps using the DevKit gcc, I'd appreciate it. 
Perhaps gendef.exe might be included in DevKit... Off to make the suggestion.

Thanks!

mc2

unread,
Aug 11, 2013, 4:22:10 PM8/11/13
to rubyin...@googlegroups.com

Luis Lavena

unread,
Aug 11, 2013, 4:23:41 PM8/11/13
to rubyin...@googlegroups.com
Hello,

On Sun, Aug 11, 2013 at 4:52 PM, mc2 <mark.c...@gmail.com> wrote:
the command: gem install mysql2 --platform=ruby -- --with_opt-dir=C:\mysql-connector-c-noinstall-6.0.2-winx64

The option is --with-opt-dir, there is no underscore in there.

Please also note that the mysql connector lib do not work out of the box and needs to be regenerated, see the usage of gendef prior on this thread.
 

did not work for me, Error:
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
*** 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.

but I now realize didn't run it from C:\Ruby200-x64\bin I don't think that should matter. 

in a default command prompt, I had success with:
gem install --platform=ruby mysql2 -- --with-mysql-lib=C:\mysql-connector-c-noinstall-6.0.2-winx64\lib --with-mysql-include=C:\mysql-connector-c-noinstall-6.0.2-winx64\include


Here you used --with-mysql-lib and not --with-opt-dir or --with_opt-dir (which was wrong). If you want to discard a failure, you need to be consistent in the options given.
 
And after copying libmysql.dll to C:\Ruby200-x64\bin, creating the development db, setting the right connection string in \config\database.yml, rails server finally works.

Thanks for all help, and not to complain unduly, but using the pre-patched ZIP is a security hole for a production server. 

If someone could create some short instructions for making gendef.exe from http://sourceforge.net/projects/mingw-w64/, perhaps using the DevKit gcc, I'd appreciate it. 
Perhaps gendef.exe might be included in DevKit... Off to make the suggestion.


I see you openened a request for gendef in GitHub, gendef is not provided as binary so that will require compilation prior building the DevKit which adds more complexity (also, it forces to do a new DevKit release)

I'm working on fixing this in mysql gem and not at RubyInstaller.

mc2

unread,
Aug 11, 2013, 6:00:13 PM8/11/13
to rubyin...@googlegroups.com
Sorry for the confusion, 

On Sunday, August 11, 2013 1:23:41 PM UTC-7, Luis Lavena wrote:
Hello,

On Sun, Aug 11, 2013 at 4:52 PM, mc2 <mark.c...@gmail.com> wrote:
the command: gem install mysql2 --platform=ruby -- --with_opt-dir=C:\mysql-connector-c-noinstall-6.0.2-winx64

The option is --with-opt-dir, there is no underscore in there.

I meant the string as copied from Badal's post above. I did catch the underscore/dash and did run the following which could not create makefile on my Windows 7 machine:
gem install mysql2 --platform=ruby -- --with-opt-dir=C:\mysql-connector-c-noinstall-6.0.2-winx64
  
Please also note that the mysql connector lib do not work out of the box and needs to be regenerated, see the usage of gendef prior on this threa
Yes, used pre-patched ZIP of the C Connector 6.0.2 64-bit: https://copy.com/CHZ4eT4us6f1 
 
I had success with:
gem install --platform=ruby mysql2 -- --with-mysql-lib=C:\mysql-connector-c-noinstall-6.0.2-winx64\lib --with-mysql-include=C:\mysql-connector-c-noinstall-6.0.2-winx64\include
And hoped to help by pointing that out. If there's a need to debug why the --with-opt-dir flag isn't working, I'll be happy to help out further, otherwise I think I've done enough damage for now :)

ke...@novafabrica.com

unread,
Oct 7, 2013, 10:14:42 AM10/7/13
to rubyin...@googlegroups.com
Luis,

I am very interested in any progress that has been made on this issue.  I am recording an online training video with instructions for beginners to get everything installed for Rails development (Windows 8 + Ruby 2.0 + DevKit + MySQL 5.6 + mysql2 gem + Rails 4).  If we can make it work, hundreds of beginners will be using it.  The mysql2 gem appears to compile but then seg faults when you require it.  This is a blocking issue for us.

Copying the DLL file and compiling with options is about as complicated as it can get for beginners.  Using gendef.exe, compiling new connectors, or downloading pre-compiled versions from third-party sites are not good solutions for us to recommend.

Any updates on a permanent fix or advice on workarounds would be appreciated.  I'm very grateful for all of the work you put into this software.

Thank you,
Kevin

BMWX5

unread,
Jan 3, 2015, 4:12:27 PM1/3/15
to rubyin...@googlegroups.com
So based on your findings are there any straight forward installation as yet. This has been killing me to no avail. Please reply back with a link to the initial straight forward installation.

Thanks
BMWX5

Richard Campbell

unread,
Jan 8, 2015, 9:56:08 AM1/8/15
to rubyin...@googlegroups.com
This is only broken on 64 bit.  If you need it working now just use 32 bit.
Reply all
Reply to author
Forward
0 new messages