Building mysql extension/gem with MinGW (was Re: Gem build issues Ubuntu 9.10 64 bit)

On Thu, Jan 14, 2010 at 5:26 PM, Eric C.
[email protected] wrote:

On Jan 13, 10:36 pm, Dale A. [email protected] wrote:

No definition for field_name
Luis L.

Ugh, I top-posted AND forgot to change the subject line. Sorry!

On Jan 14, 9:11 pm, Eric C. [email protected]
wrote:

[email protected] wrote:

Since people are talking about the mysql gem, I thought I’d ask how
you can build it under MinGW. I can’t seem to make any combination of
extconf switches work.

–with-mysql-dir is the only switch that you need, or --with-mysql-
include and --with-mysql-lib

I have the standard Windows mysql-5.1.42-win32 installed in
/usr/local/mysql. Do I need some MinGW-specific version? (I’ve tried
compiling it from source with MSYS/MinGW and also Cygwin, with no
success.)

You’re talking about RubyInstaller and combined with DevKit, correct?

If so, then don’t install form inside bash or use *nix like paths.

If you have MySQL 5.1, you need:

  1. RubyInstaller 1.9.1 installed
  2. DevKit installed and configured (edit fstab as indicated in the
    wiki)

http://wiki.github.com/oneclick/rubyinstaller/development-kit

  1. From a Windows prompt, ensure Ruby and GCC works:

ruby -v
gcc --version

  1. Have MySQL installed and know the path where its library is. If you
    manually extracted it form the zip, remember the location.

  2. proceed to gem installation and indicate the “ruby” platform to
    force the compilation. Now use the path to MySQL

gem install mysql --platform ruby – --with-mysql-include=C:/mysql/
include --with-mysql-lib=C:/mysql/lib/opt

I’ve indicated “opt” as library because is the "opt"imized version.

Please note that extracting or installing MySQL or Ruby or gems in a
path with spaces can be a problem. Try avoiding them to all cost.

Hope that helps.

On Fri, Jan 15, 2010 at 2:05 PM, Luis L. [email protected]
wrote:

include and --with-mysql-lib
OK. Using the instructions below, just --with-mysql-dir doesn’t quite
work (perhaps because the libs aren’t right in lib/), but -include
with -lib works.

I have the standard Windows mysql-5.1.42-win32 installed in
/usr/local/mysql. Do I need some MinGW-specific version? (I’ve tried
compiling it from source with MSYS/MinGW and also Cygwin, with no
success.)

You’re talking about RubyInstaller and combined with DevKit, correct?

If so, then don’t install form inside bash or use *nix like paths.

Ah, yes. OK.

include --with-mysql-lib=C:/mysql/lib/opt

I’ve indicated “opt” as library because is the "opt"imized version.

Please note that extracting or installing MySQL or Ruby or gems in a
path with spaces can be a problem. Try avoiding them to all cost.

Hope that helps.

Yes, that allows me to build the gem with no problems.

However, I would still like to build from the tarball (since I am
working on a modified version of it). I used this command line to find
out what exact steps gem was taking:

gem install mysql --verbose --platform ruby --

–with-mysql-include=C:/MySQL/include
–with-mysql-lib=C:/MySQL/lib/opt

That showed, as expected, that the extconf command line is:

C:/Ruby/bin/ruby.exe extconf.rb

–with-mysql-include=C:/MySQL/include --with-mysq
l-lib=C:/MySQL/lib/opt

But when I issue this command myself in the source directory, extconf
fails to find mysql_query. What am I doing wrong? I am using cmd.exe
for both, and my environment should be the same. I wonder if gem has
its own environment that it passes to ruby/extconf.

On Fri, Jan 15, 2010 at 6:29 PM, Eric C.
[email protected] wrote:

–with-mysql-dir is the only switch that you need, or --with-mysql-

success.)

You’re talking about RubyInstaller and combined with DevKit, correct?

If so, then don’t install form inside bash or use *nix like paths.

Ah, yes. OK.

I just discovered that building the gem actually works fine in MSYS
also; and I can either use DOS-style or Unix-style pathnames for the
MySQL directories.

  1. From a Windows prompt, ensure Ruby and GCC works:
    gem install mysql --platform ruby – --with-mysql-include=C:/mysql/

C:/Ruby/bin/ruby.exe extconf.rb
–with-mysql-include=C:/MySQL/include --with-mysq
l-lib=C:/MySQL/lib/opt

But when I issue this command myself in the source directory, extconf
fails to find mysql_query. What am I doing wrong? I am using cmd.exe
for both, and my environment should be the same. I wonder if gem has
its own environment that it passes to ruby/extconf.

I’m still trying to figure out this aspect of the problem. At least
compiling the extension through gem fixed a bug I saw with the binary
gem – before, the query method always failed, saying it was not
connected, even though I had connected successfully (as demonstrated
by #list_dbs and #list_tables).

OT: I’m just starting to use Gmail for mailing lists. I notice that it
keeps incorrectly considering some of my original text as quotations,
while some quotations it doesn’t detect as such. Is there any way to
fix that?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs