From: "Curt Hibbs" <ml.chibbs / gmail.com>
>
> Below, Ara argues that a VC2005 version of Ruby would be unable
> to compile/use extensions built with the command sequence:
> 
>   ruby extconf.rb
>   make
>   make install
> 
> Isn't this incorrect? Wouldn't the sequence just become:
> 
>   ruby extconf.rb
>   nmake
>   nmake install
> 
> If I'm wrong here, please let me know.

Ara has already covered this in detail, but to clarify:

  ruby extconf.rb
  nmake
  nmake install

can indeed work on Windows, for simple extensions.

It's not uncommon, at a minimum, to have to tweak the
extconf.rb, though.  Often an extconf.rb specifies
gcc-specific compiler flags, or looks for the presence
of libraries that are named differently, etc.

Sometimes it's a simple fix, such as modifying the
extconf.rb to eliminate lines like:

  CFLAGS << " -Wall -Wno-comment"
  CFLAGS << " -Wno-unused"

...on the Windows build.


But for more complex extensions, building on windows
(with nmake and cl.exe) can be far less trivial.

I recently compiled the RMagick extension on Windows,
and it was a complete hack job to get it to compile
with microsoft's tools.

First of all, RMagick uses ./configure to actually
build the extconf.rb from extconf.rb.in.
So there's no extconf.rb to even work with initially.

It also uses ./configure to build a lengthy header
file, rmagick_config.h.

Ultimately, I ended up building RMagick on linux,
and bringing extconf.rb and rmagick_config.h back
to Windows, and tweaking them enough to compile with
nmake + cl.exe.

Here's an example of the tweaks to extconf.rb:

Replace:

  $CFLAGS = "-Wall -g "
  $CPPFLAGS = "-DRUBY_VERSION=#{VERSION_NUMBER} -I/opt/include/ImageMagick-6.2.8"

with:

  $CFLAGS = "-DWIN32 -DRUBY_VERSION=#{VERSION_NUMBER} -I../../../ImageMagick-6.2.8"
  $LIBPATH << "../../../ImageMagick-6.2.8/VisualMagick/lib"

etc.


And I was lucky ImageMagick itself came with the
ability to build with Visual Studio.  There are other
projects, such as the ones Ara mentioned, and puredata,
and (I think) ruby-gnome2 and ruby-gstreamer that don't
build under visual studio at all.


So, yeah... If we could build ruby extensions AND the
libraries they rely on with ./configure && make, on
Windows...  That sounds far nicer than the current hassles
I've had trying to build complex extensions and their
associated libraries with microsoft's tools.


That said, I must admit... I tried to get mingw/msys to
work for me, and I had weird problems with it.  I asked
for help in #mingw on irc.freenode.net on a couple 
occasions, but never got a response.  But clearly, Ara
has gotten it to work, so there's hope.  <grin>



Regards,

Bill