Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

sodabrew opened this issue Dec 27, 2013 · 13 comments
Milestone

Comments

@sodabrew
Copy link
Collaborator

@sodabrew sodabrew commented Dec 27, 2013

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

This comment has been minimized.

Copy link
Collaborator Author

@sodabrew sodabrew commented Dec 27, 2013

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

This comment has been minimized.

Copy link
Collaborator Author

@sodabrew sodabrew commented Dec 27, 2013

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

This comment has been minimized.

Copy link

@phasis68 phasis68 commented Dec 28, 2013

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

This comment has been minimized.

Copy link
Collaborator Author

@sodabrew sodabrew commented Dec 28, 2013

Just reading your comment now.

Thank you for posting a method of discovering the dll problem at compile time!

I will open a bug to re-fix the version detection for 0.3.15.

@aaron-ashmore

This comment has been minimized.

Copy link

@aaron-ashmore aaron-ashmore commented Dec 28, 2013

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

This comment has been minimized.

Copy link
Collaborator Author

@sodabrew sodabrew commented Dec 28, 2013

@sodabrew

This comment has been minimized.

Copy link
Collaborator Author

@sodabrew sodabrew commented Dec 28, 2013

@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

This comment has been minimized.

Copy link
Collaborator Author

@sodabrew sodabrew commented Sep 28, 2014

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

This comment has been minimized.

Copy link
Collaborator Author

@sodabrew sodabrew commented Oct 2, 2014

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

This comment has been minimized.

Copy link
Collaborator Author

@sodabrew sodabrew commented Oct 5, 2014

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 comment has been minimized.

Copy link

@SleeplessByte SleeplessByte commented Oct 6, 2014

This is great!

@sodabrew

This comment has been minimized.

Copy link
Collaborator Author

@sodabrew sodabrew commented Oct 24, 2014

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

This comment has been minimized.

Copy link
Collaborator Author

@sodabrew sodabrew commented Oct 30, 2014

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
Projects
None yet
4 participants
You can’t perform that action at this time.