Detect and warn if libmysql.dll requires gendef.exe fix #469

Closed
sodabrew opened this Issue Dec 27, 2013 · 13 comments

4 participants

@sodabrew
Collaborator

The failures seen on 64-bit Windows with 64-bit Ruby and 64-bit MySQL all appear to be due to libmysql.dll that is missing some form of linkage data.

What I'd like to do is find a way to detect and warn the user if their libmysql.dll needs to be regenerated with the additional linkage information. Compile time detection would be good, runtime detection would be great.

A fix is described at: https://bugs.ruby-lang.org/issues/8591

This supersedes our issues: #372, #430 (add more to this list as needed).

@sodabrew
Collaborator

I found these related issues that @luislavena also experienced, did you make any progress on these?
http://bugs.mysql.com/bug.php?id=49934
http://permalink.gmane.org/gmane.comp.gnu.mingw.w64.general/1032

@sodabrew
Collaborator

Version 6.1.3 of the MySQL Connector/C was just released, let's see if the problem is fixed:
http://dev.mysql.com/doc/relnotes/connector-c/en/news-6-1.html

@phasis68

Did you consider my last comment at https://bugs.ruby-lang.org/issues/8591?
The above two issues of @luislavena ,which is cross compiling issue, are not related with this issue.
And The version 6.1.3 of the MySQL Connector/C did not solve this issue.

@sodabrew
Collaborator
@aaron-ashmore

Ok sorry if i sound dumb im just getting into rails and taking a class but how do i update the connector so that i can host using webrick...?

@sodabrew
Collaborator

@phasis68 suggests this detection code for extconf.rb:

if RUBY_PLATFORM =~ /x64-mingw32/
  abort "-----\nWrong version of libmysql.lib\n-----" unless have_func('__libmysql_lib_iname')
end
@sodabrew sodabrew added this to the 0.3.17 milestone Jul 29, 2014
@sodabrew
Collaborator

I've been hacking on this recently!

I discovered that if I link the file libmysql.lib from the MySQL Connector/C distribution into mysql2.so, then I don't need to gendef or modify libmysql.dll at all - I just need to put the DLL file into the Ruby bin directory - and the linker can handle it from there.

In extconf.rb, at the bottom, I added:

$LOCAL_LIBS << ' ' << File.expand_path("#{libdir}/libmysql.lib")

and it appeared in the right place in tmp/mingwx64.../Makefile.

I also discovered that I can use the stdlib Win32API module to call LoadLibrary (from Kernel32.DLL) and give a full path to the libmysql.dll file I want to use, without copying the DLL to the Ruby bin directory! I would like to use this capability to put libmysql.dll into the mysql2 gem directory to create a self-contained driver.

(That code snippet is in my Windows VM, but I don't have a shared clipboard nor ssh in there, so getting the changes out is a pain!)

@sodabrew
Collaborator

Ok, so linking libmysql.lib doesn't seem to fix x64 builds after all. Not sure how I had it working and then not working anymore, but... huh.

Take a look at reimp.exe here:
http://www.mingw.org/wiki/msvc_and_mingw_dlls
http://www.openwebspider.org/documentation/how-to-link-libmysqllib-with-dev-c-or-gcc-under-windows/

@sodabrew
Collaborator

Answer: because I had built a libmysql.a and that was getting linked instead of libmysql.lib. The mingw64 branch now builds and runs specs on Windows x64. Goodness, that was a pain. Code is at #473.

@SleeplessByte

This is great!

@sodabrew
Collaborator

PR #473 resolves this issue. I am closing this issue to focus new comments onto that PR.

@sodabrew sodabrew closed this Oct 24, 2014
@sodabrew
Collaborator

Windows users: please read and comment at #473 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment