Ruby on Windows

Is it just me, or is getting anything other than standard ruby a true
ordeal on Windows?

Now I'm sure everyone is snickering right about now, that's OK.

Anyway, I'm trying to write a product using Ruby that will be
downloaded and run locally. I need to support different databases.
MySQL has native Windows binaries. Looking for Ruby bindings to MySQL
led me to http://www.tmtm.org/en/mysql/ruby/. So I download the
archive, extract it, run ruby extconf.rb, and it stops there.

It can't find mysql_query in any of the library paths that it looks
at. So I look at the log file and see that it is basically generate
mini-C programs and if they compile, the stuff is there.

On Windows, there is a mysqlclient.lib file that it is trying to link
to. Hm...why would it still show up unresolved?

Fast forward 3 hours of digging through mkmf to figure out how it is
generating paths... Screw this. I'll just generate the C file myself
and write my own project to generate the library. That wasn't too
hard. Got the project going. Got the shared library compiled.
Hm...where do I put the file? Ah...I put it in the i386-msvcrt
directory in site_ruby. Hm...everything in there is a .so file.
OK...I'll rename mine to mysql.so (is this necessary?)

Now I'll go and do this -

    require 'mysql'

Run this through the interpreter...

Get this...

C:/shared/tools/sdks/ruby/lib/ruby/1.8/i386-mswin32/mysql.so: 127: The
specified procedure could not be found. - Init_mysql (LoadError)
C:/shared/tools/sdks/ruby/lib/ruby/1.8/i386-mswin32/mysql.so from
connect.rb:1

Look at my C project, Init_mysql does exist. But it isn't exported.
In the Windows world, I have to export functions from DLLS. So that
things like GetProcAddress work. So I start off by exporting the one
method.

Rerun the interpreter, no errors. WOOHOO!!!

So I extend the script to this...

   require 'mysql'

   c = Mysql.new('localhost', 'root', 'my_root_password')

   c.list_dbs.each { |db|
      p db
   }

I get a list of all Databases in MySQL instance. Try some inserts,
deletes, etc. Everything seems to be working.

Now here are my problems -
* This took 6 hours
* extconf gave me no ideas that it required a C compiler
* extconf gave me no ideas what was going wrong (I just got a no)

I'm a pretty decent Windows programmer (been doing it for 10+ years
now). And I think I've got to go through the whole process again to
get Ruby DBI working and SQLLite/Ruby (which I probably won't use
since it is GPL). And PostgresQL. But for someone starting out with
Ruby on Windows, would they know they needed a C compiler? Would they
know they needed to add __declspec(dllexport) to that one function?

Now let's contrast this with Python. I go to
http://sourceforge.net/projects/mysql-python/ and they have an EXE I
can download, run it, and I can connect to MySQL in under 5 minutes
(after download).

I love Ruby. And a lot of that love comes from Rails (which I've been
using quite successfully). But building an app is harder than it
should be.

I'm going to document what I did and post it on my weblog along with
the binary file that I generated. Hopefully someone else out there
can make use of it.

···

--
Justin Rudd
http://seagecko.org/thoughts/

Also...just so know one thinks I don't know how to use Google...

I did find http://raa.ruby-lang.org/project/mysql-ruby-win/\. But it
didn't work for me using MySQL 4.0.20.

And I'm aware of the Pure Ruby implementation here
(http://raa.ruby-lang.org/project/ruby-mysql/\). It even comes with
Rails. But it isn't as fast, but it is good to test with.

···

On Thu, 9 Sep 2004 12:55:15 -0700, Justin Rudd <justin.rudd@gmail.com> wrote:

Is it just me, or is getting anything other than standard ruby a true
ordeal on Windows?

Now I'm sure everyone is snickering right about now, that's OK.

Anyway, I'm trying to write a product using Ruby that will be
downloaded and run locally. I need to support different databases.
MySQL has native Windows binaries. Looking for Ruby bindings to MySQL
led me to http://www.tmtm.org/en/mysql/ruby/\. So I download the
archive, extract it, run ruby extconf.rb, and it stops there.

It can't find mysql_query in any of the library paths that it looks
at. So I look at the log file and see that it is basically generate
mini-C programs and if they compile, the stuff is there.

On Windows, there is a mysqlclient.lib file that it is trying to link
to. Hm...why would it still show up unresolved?

Fast forward 3 hours of digging through mkmf to figure out how it is
generating paths... Screw this. I'll just generate the C file myself
and write my own project to generate the library. That wasn't too
hard. Got the project going. Got the shared library compiled.
Hm...where do I put the file? Ah...I put it in the i386-msvcrt
directory in site_ruby. Hm...everything in there is a .so file.
OK...I'll rename mine to mysql.so (is this necessary?)

Now I'll go and do this -

    require 'mysql'

Run this through the interpreter...

Get this...

C:/shared/tools/sdks/ruby/lib/ruby/1.8/i386-mswin32/mysql.so: 127: The
specified procedure could not be found. - Init_mysql (LoadError)
C:/shared/tools/sdks/ruby/lib/ruby/1.8/i386-mswin32/mysql.so from
connect.rb:1

Look at my C project, Init_mysql does exist. But it isn't exported.
In the Windows world, I have to export functions from DLLS. So that
things like GetProcAddress work. So I start off by exporting the one
method.

Rerun the interpreter, no errors. WOOHOO!!!

So I extend the script to this...

   require 'mysql'

   c = Mysql.new('localhost', 'root', 'my_root_password')

   c.list_dbs.each { |db|
      p db
   }

I get a list of all Databases in MySQL instance. Try some inserts,
deletes, etc. Everything seems to be working.

Now here are my problems -
* This took 6 hours
* extconf gave me no ideas that it required a C compiler
* extconf gave me no ideas what was going wrong (I just got a no)

I'm a pretty decent Windows programmer (been doing it for 10+ years
now). And I think I've got to go through the whole process again to
get Ruby DBI working and SQLLite/Ruby (which I probably won't use
since it is GPL). And PostgresQL. But for someone starting out with
Ruby on Windows, would they know they needed a C compiler? Would they
know they needed to add __declspec(dllexport) to that one function?

Now let's contrast this with Python. I go to
MySQL for Python download | SourceForge.net and they have an EXE I
can download, run it, and I can connect to MySQL in under 5 minutes
(after download).

I love Ruby. And a lot of that love comes from Rails (which I've been
using quite successfully). But building an app is harder than it
should be.

I'm going to document what I did and post it on my weblog along with
the binary file that I generated. Hopefully someone else out there
can make use of it.

--
Justin Rudd
http://seagecko.org/thoughts/

--
Justin Rudd
http://seagecko.org/thoughts/

Is it just me, or is getting anything other than standard ruby a true
ordeal on Windows?

Now I'm sure everyone is snickering right about now, that's OK.

well, not _everyone_, but I'd bet quite a few.

Now here are my problems -
* This took 6 hours
* extconf gave me no ideas that it required a C compiler
* extconf gave me no ideas what was going wrong (I just got a no)

I'm a pretty decent Windows programmer (been doing it for 10+ years
now). And I think I've got to go through the whole process again to
get Ruby DBI working and SQLLite/Ruby (which I probably won't use
since it is GPL). And PostgresQL. But for someone starting out with
Ruby on Windows, would they know they needed a C compiler? Would they
know they needed to add __declspec(dllexport) to that one function?

Depends on background. I've done perl in the past, and knew there
would be limitations when I stuck my nose into Ruby (about a month
ago? maybe more).

Now let's contrast this with Python. I go to
MySQL for Python download | SourceForge.net and they have an EXE I
can download, run it, and I can connect to MySQL in under 5 minutes
(after download).

Where did the EXE come from? Some kind soul with a bit of c compiler
experience like yourself I'd imagine. With any luck, soon there will
be more EXE files on RubyForge thanks to you :slight_smile:

I love Ruby. And a lot of that love comes from Rails (which I've been
using quite successfully). But building an app is harder than it
should be.

There are packagers out there, granted they won't cover every possible
situation, but they do make life easier (see bottom of page
http://www.rubygarden.org/ruby?QuickGuideToPackaging\)

I'm going to document what I did and post it on my weblog along with
the binary file that I generated. Hopefully someone else out there
can make use of it.

Indeed, we will. Looking forward to it :slight_smile:

···

On Fri, 10 Sep 2004 04:55:50 +0900, Justin Rudd <justin.rudd@gmail.com> wrote:

--
Bill Guindon (aka aGorilla)

Justin Rudd wrote:

Is it just me, or is getting anything other than standard ruby a true
ordeal on Windows?

I can second much of your experience and your problems with Ruby on
windows. (I have been trough the mysql-hell myself, but have resolved it
with DBI:ODBC once and for all.)

I do think there is not enough attention being paid on making Ruby work
on windows. But I admit that there have to be porters and packagers,
people keeping the windows part alive. And with your kind of C++
experience, you seem to be predestined to contribute that way.

In the way of tools, I have found the mingw package to work miracles,
since it is pretty much unix-like. extconf.rb scripts work pretty much
all the time under this setup, I even could compile Ruby 1.9. But not
everyone finds that mixed compilation environment to their taste: It
feels Unix, but is win32 below.

So yes, it's a good thing to publish your thoughts, but consider
contributing what you have managed to compile ! And thank you for
speaking up, I sometimes feel like I am the only windows user around
here. (And no, I am not interested in the platform discussion.)

kind regards,
kaspar

semantics & semiotics
code manufacture

www.tua.ch/ruby

Kaspar Schiess wrote:

In the way of tools, I have found the mingw package to work miracles,
since it is pretty much unix-like. extconf.rb scripts work pretty much
all the time under this setup, I even could compile Ruby 1.9. But not
everyone finds that mixed compilation environment to their taste: It
feels Unix, but is win32 below.

I prefer cygwin over mingw when going for the unix feel. All mingw has ever done for me is screw up my cygwin installations. Mingw seems to only play nice when there is no cygwin, at least for me. But if you have Visual Studio or similar I'd say go for a straight win32 compilation environment.

  And thank you for
speaking up, I sometimes feel like I am the only windows user around
here. (And no, I am not interested in the platform discussion.)

I also use Ruby on Windows. (but i use it on Mac & Linux to). So there are two of us at a minimum.

Zach

Zach Dennis wrote:

Kaspar Schiess wrote:

>
> In the way of tools, I have found the mingw package to work miracles,
> since it is pretty much unix-like. extconf.rb scripts work pretty much
> all the time under this setup, I even could compile Ruby 1.9. But not
> everyone finds that mixed compilation environment to their taste: It
> feels Unix, but is win32 below.

I prefer cygwin over mingw when going for the unix feel. All mingw has
ever done for me is screw up my cygwin installations. Mingw seems to
only play nice when there is no cygwin, at least for me. But if you have
Visual Studio or similar I'd say go for a straight win32 compilation
environment.

> And thank you for
> speaking up, I sometimes feel like I am the only windows user around
> here. (And no, I am not interested in the platform discussion.)
>
I also use Ruby on Windows. (but i use it on Mac & Linux to). So there
are two of us at a minimum.

The One-Click Installer for Ruby has been pushing close to 150 downloads a
day and over a total of 14,000 downloads since last February. So, there
might be a few more people using Ruby on Windows out there. :wink:

Curt