Ruby on Rails
Win32MingwInstall

How to download ruby 1.8.6 from svn, compile with mingw with extensions

This has been superceded by Luis’ ‘sandbox’ mingw installer, which does this all for you :)

http://rubyinstaller.rubyforge.org/wiki/wiki.pl?Mingw

What next follows are Roger Pack’s notes on the same—not complete steps yet, so if confused ask.*

If you’d like to follow them, I suggest you click “edit” at the bottom, and just use the straight text, as the wiki text has formatting issues still.

I think Luis Lavena automates these (or similar) steps in

If you just want to get a pre-built binary version (p110), go to http://doachristianturndaily.info/ruby_distro

download mingw one-click install. install somewhere.

So these days, I believe you can get it ‘self bootstrapping’ from http://code.mmediasys.com/installer3/latest.zip [requires you have another version of ruby already installed].

Or download a compiled binary from http://dump.mmediasys.com/installer3/

Now the install instructions if you want to rebuild the mingw environment by HAND from scratch [automated way listed above].
Note that these may not be perfect with all packages.

background:

mingw is “GCC for windows straight” — it runs off itself and the folders located within itself (/include /lib, etc.)

install somewhere (no spaces)

download and install msys itself
# this is the default build utilities and things, basically a cross between DOS and linux so that you can have a working “./configure”
#install it somewhere else, and when it asks for the location of mingw, enter it in lowercase! Otherwise you won’t be able to compile anything.

download msys-dtk-1.0.1’ one click package, install. (under MSYS Base system: Current release).

turns out there are two ways to get the ‘development staples’ after installing GCC itself (mingw) and a build environment (msys). Either download them piece-wise from “technology preview: tools for msys” or there is a one-clicker under “msys-dtk1.0.1” (the one-clicker contains more stripped down version). Look carefully for an exe under dtk to find it.

If you go the one-click route, realize you will be missing several very important ruby dependencies—like iconv, zlib, and openssl, and gettext.
So let’s install those missing pieces from the piece-wise hefty installer (why there is no one-click for that, I have no idea).

underneath Technology Preview: Tools for MSYS-1.0.11
These tools have some that are built “in msys land” or “msys mode” which means they use the unix style old directories. Avoid them.
Some have bin versus src. Src. will have a ‘mingwport’ sub thing (described later—ignore it), and a src tar ball, that you can build with (untar+gz it).
gettext (I think you don’t need the dll—that’s only if someone were to download the sources, and do a ‘dynamic link’ against gettext, instead of a static link—a la http://clbianco.altervista.org/gnupg/eng/gnupg.html)
so with those I think (I think) you can download src and bin and not have to compile anything (remember to unzip it into /mingw for gcc’s use!)
failing that when you download the ‘src’ version it will have a ‘mingwport’ directory—go in there, run the mingwPort.sh (assuming you already have wget) and specify /mingw as your install path and it should download it (again) and work. I’m not sure what these are, what they mean exactly yet. I think the dll is only if you were to link dynamically against the library, so is probably not needed.
Note: still haven’t really figured out how to install gettext—look at that url for how to do it).

when installing ports, you must specify that they go to /mingw (and also when you use ./configure —prefix=c:/mingw or what not)

Also as a note with gettext, apparently some of these are compiled to be used in the linking process (so internally they will use the funky dir system instead of normal windows ones)—you want to download the non MSYS versions, AFAIK. (http://sourceforge.net/project/shownotes.php?group_id=2435&release_id=540763)
libiconv (I think you need the dll).
Also with gettext apparently you can

just get teh src and apply a small patch and it will work for you. (http://www.venge.net/mtn-wiki/BuildingOnWindows tells you how to do your own port.)

openssl from there looks good, too.

To install these you unzip them in your mingw directory (or enter the msys ‘console’, unzip them in root).

The others listed there might be necessary to do a ‘complete’ build (from svn repository), which requires some more build tools, like automake. We are using the daily snapshot, which already has ‘./configure’ built, so we don’t need automake (unless we want it later).

Now the general rule for other libs is 1) if there’s a port, you want to use that. It may mean there were minor tweaks made to the package, to make it work right. If there is none you can just download and install straight. In my experience things with ports sometimes download straight and work, too, but hey, maybe there’s something useful in the port.

install zlib port http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=233332&release_id=511579
zlib

zlib.dll will be located at you MinGW bin folder, which is where MinGWport install it (may want to copy that to your ruby\bin folder, or somewhere in your path).

regex is also listed there under miscellany—not sure if it’s necessary or not.

Now let’s get readline which is a patch in the tracket at sourceforge. (tracker→mingw port submission)
1) install wget
2) download readlinemingw.port (or whatever it’s called there)
3) unzip it somewhere
4) run “./mingwport.sh” in the unzipped directory (downloads and extracts, builds and installs it)

openssl: (from http://tor.eff.org/svn/trunk/doc/tor-win32-mingw-creation.txt)
Download, extract, compile openssl
———————————————————————

Download openssl:
http://www.openssl.org/source/openssl-0.9.8e.tar.gz

Extract openssl:
Type “tar zxf openssl-0.9.8g.tar.gz”

Make openssl libraries:
cd openssl-0.9.8g/
./Configure -no-idea -no-rc5 -no-mdc2 mingw —prefix=c:/mingw

!!!Edit Makefile and remove the “test:” and “tests:” sections.!!! (anything that says
TESTSOMETHING:
some stuff

rm -rf ./test
cd crypto/
find ./ -name “*.h” -exec cp {} ../include/openssl/ \;
cd ../ssl/
find ./ -name “*.h” -exec cp {} ../include/openssl/ \;
cd ..
cp *.h include/openssl/

  1. The next steps can take up to 30 minutes to complete.
    make
    make install

All right ready to rock and roll

unzip the stable-release
in the msys console
./configure —with-winsock2 —enable-shared —prefix=c:/ #not sure if either of those 2 isnecessarywinsock2 necessary, or if prefix works at all.
make
#At this point you should check the output for ‘compiling readline’
#‘compiling zlib’ etc… and see if everything worked.
make check # to run tests
make install (from a dos shell this time)

http://wiki.videolan.org/Win32CompileMSYS#MinGW
http://www.ruby-forum.com/topic/126102#new (the good one)
http://www.ruby-forum.com/topic/59411#new also ok
http://www.ruby-forum.com/topic/125692#new says a little on how to build it with VC2003
http://rubyforge.org/pipermail/wxruby-users/2003-August/000005.html describes this process again, slightly.

That will create bin/lib/man/share in the root of your drive (thats
because generated make file isn’t compatible with MSYS).

You should have there a working implementation.

if gcc.exe says “no files found” that means “your msys and mingw directories are the same—bad!”

When you try to compile extensions use the miniruby.exe as it uses that ruby’s path for some of the library loads.

May want to rename your cygwin directory temporarily to ensure there aren’t conflicts.

Running configure twice fails.
One got a weird “sed -e not found” or something—redownload your ruby distro.

Tell them to enable all always log messages :)

Tell gettext they need small help there (filezille gettext)

To install wget it may say

No file to patch. Skipping patch.
1 out of 1 hunk ignored
./mingwPORT.sh: cd: /usr/src/wget-1.9.1/..: No such file or directory
cat: /tmp/wget-1.9.1.tar.gz.log: No such file or directory

but still builds wget.exe —copy it to a bin dir (might not be necessary).

Add some links to the mingw stuff to good stuff here :)

Note with rmagick—do not attempt to compile this from scratch! It corrupts Ruby! (your String.dump command will start inserting garbage at the end). Download and install the precompiled version for windows.

Note that if you don’t have a working ext you might be able to get an old one from the old OCI! and just drop it in (and any associated .dll’s). Viola.
Like for openssl, openssl.so to i386-mingw (fake it out), copy bin/ssleay32.dll, libeay32.dll to your bin and I think it works. No build necessary. Also look for any files named ‘openssl’ and copy them over.

./configure —enable-apache2=/c/Apache2/bin/apxs.pl —with-ssl=/c/OpenSSL CPPFLAGS=‘-I/usr/local/mingw/include’ LDFLAGS=‘-L/usr/local/mingw/lib’

http://www.mail-archive.com/openssl-users@openssl.org/msg43354.html
lists some things on openssl err I originally got

make1: * No rule to make target `../include/openssl/crypto.h’, needed by `cryptlib.o’. Stop.
means ‘you need better instructions for a mingw install’

todo tell openssl not workin’ too great

The procedure entry point REcolorImage CORE_RL_magick_.dll
might mean ‘you have conflicting version of imagemagick and rmagick gem’ or it might mean ‘msvc and mingw don’t mix’ or something.

Or maybe ‘you need a new dll’ or something

Note that any .so’s anywhere in there will be loaded into ruby—in fact even if they’re named .sob or anything in the lib directory—it all goes in.

DONE. Hopefully.

OLD INSTRUCTIONS PLEASE IGNORE: -

How to install ruby 1.8.6 with gems and zlib using win32 and mingw.

get mingw+msys to work
get ruby svn
compile it (hopefully works)
install it (not done—might help next process)

finally get it, compile it [—prefix=c:/whatever—or /whatever_ruby_dir which all seem to cause problems—relative path seems safe, though]

smallish error on install step], get gem guy, set rubylib, run setup.rb (might

need \.lib)
copy .ext/
/.so, ext/ to lib (might not be necessary)
set path=bin
set rubylib=(whatever)/lib:(whatever)/lib/i386_mingw

compile zlib -shared (or not-you need libz.a)
cp /c/ruby_mingw/zlib-1.2.3/*.a . (zlib dir)

from ‘normal’ ruby dir [copy in files to make this work]
gcc ext/zlib/zlib.c -c cd c-I. -g -O2 -L/c/ruby_mingw/ruby

-L. -L. -lmsvcrt-ruby18-static -lz -lshell32 -L/c/ruby_mingw/zlib-1.2.3/

-I/c/ruby_mingw/zlib-1.2.3 libz.a -lwsock32 win32.o

gcc -shared -W1,-soname,zlib.so -o zlib.so zlib.o libz.a libmsvcrt-ruby18.dll.a

now go to rubygems, run ruby setup.rb from DOS shell
ruby setup.rb all —prefix=/c/whatever
now massage it

Melissa@MELISSA-PACK /c/ruby_mingw/rubygems_real/lib
$ cp *.rb /c/ruby_mingw/ruby/lib

Melissa@MELISSA-PACK /c/ruby_mingw
$ cp -r ./rubygems_real/lib/rubygems ruby/lib

note:
installing rubygems seems to err if you install it away from where your rubylib is

set to.
it also seems to dislike installing it in a subdir
like /special/path/to/ruby — bad.

above should combat this:

make1: Entering directory `/c/ruby_mingw2/ext/zlib’
gcc -I. -I../.. -I../../. -I../.././ext/zlib -DOS_CODE=OS_WIN32 -g -O2 -c

checker.c
checker.c:4:19: zlib.h: No such file or directory
checker.c: In function `t’:
checker.c:8: error: `deflateReset’ undeclared (first use in this function)
checker.c:8: error: (Each undeclared identifier is reported only once
checker.c:8: error: for each function it appears in.)
make1: * [checker.o] Error 1
make1: Leaving directory `/c/ruby_mingw2/ext/zlib’
make: *
[all] Error 1
or you can ignore it (delete zlib subdir, rerun)

If it doesn’t install to the right dir, do this
./miniruby.exe ./instruby.rb —dest-dir=“c:/ruby_mingw3” —extout=“.ext”

—make=“make” -mflags=" —unix" —make-flags=" —unix" —inst
alled-list .installed.list —mantype=“man”

edit rbwhtever.rb after install

now some notes

ec.o random.o range.o re.o regex.o ruby.o signal.o sprintf.o st.o string.o struct.o time.o util.o variable.o version.o fileblocks.o crypt.o flock.o win32.o dmyext.o msvcrt-ruby18.res.o -lshell32 -lwsock32 -o msvcrt-ruby18.dll
Creating library file: libmsvcrt-ruby18.dll.a
-e:1: syntax error, unexpected tSTRING_BEG, expecting $end
…nk “msvcrt-ruby18.dll”, link}".
^
compiling Win32API
make1: Entering directory `/c/ruby_mingw2/ext/Win32API’
mkdir -p ../../.ext/i386-mingw32
gcc -I. -I../..

if it says
:\ruby_mingw2>gem which
:/ruby_mingw4/lib/ruby/1.8/rubygems.rb:489:in `require’: no such file to load — rbconfig/datadir (LoadError)
from c:/ruby_mingw4/lib/ruby/1.8/rubygems.rb:489
from c:/ruby_mingw4/bin/gem.bat:16:in `require’
from c:/ruby_mingw4/bin/gem.bat:16

that meant ’your ruby gems was only half installed! — delete environment variable RUBYOPT=-rubygems and try again.
What it really might mean, though is that your lib\(something) rbconfig.rb file is corrupted with the wrong directory.

Note if you install rake you will need to create your own rake.bat
c:\ruby_mingw4\bin\ruby -x “c:/ruby_mingw4/bin/rake” %1 %2 %3 %4 %5 %6 %7 %8 %9

similarly for rails.

If it complains of ITIMER or what not I think that may mean your msys path is messed up—reinstall, make sure /etc/fstab has no caps.

for rmagick on mingw:
download graphicsmagick (install without perl)
./configure
make
make install
then rmagick
configure
make (ignore errors)
make install.

now rmagick still messes up string.dump, so we will write out own (add this to application.rb
require ‘rmagick’
class ::String
alias :dump_old :dump
def dump # overwrite rmagick’s cruddy dump
out_string = ‘"’
self.each_byte { |b|
if (b < 32 or b > 127) and b != 9 and b != 10# leave them—why not?
out_string << “\\%03d” % b # octo it
elsif b == “\\”0
out_string << ‘\\’ # dual back slash
elsif b == 34
#print “quote”
out_string << “\\\”" # " → \"
else
out_string << b # leave it
end
}
out_string << ‘"’
end

iconv:

configure && make it

this will install a lot of junk—search for libiconv.a or whatever it is, copy to local directory (source sirectory), then compile it similar to the zlib stuff (have to pass -I to its includes, etc.).

gcc -shared -W1,-soname,iconv.so -o iconv.so iconv.o libmsvcrt-ruby18.dll.a libiconv.dll.a

copy that to your bin/ruby/blah/blah/i386-mingw dir.

Download the iconv ‘port’ on the mingw (the dll, highest number) site, put those .dll’s in the ruby bin dir. And possibly the dev port (or the real iconv src files)

mysql:
mysql for win32 seems to work (!) (also have to, of course download their whole package,
but that’s normal).

If you’d like readline (like ruby script\console requires), get and install (somehow) from http://sourceforge.net/tracker/index.php?func=detail&aid=1599368&group_id=2435&atid=752210)
http://www.mingw.org/MinGWiki/index.php/mingwPORT instructions at bottom.

Also you may want to get openssl (get the whole developer’s toolkit, really—you need most of those binaries, and its there to help you set things up).

Note if you get a blank screen on a rails page, it may mean a templateerror is being thrown, like that you don’t have openssl installed.

readline: to install, from ai previous VC distro “readline.so” → i38-mingw, “readline.dll” → bin

compile error
script/../config/../app/views/autos/index.rhtml:4: syntax error, unexpected $end, expecting kEND
_erbout.concat " "…
^

means ‘you have a compiled version of rmagick on win32—you want the precompiled one’ You may need to manually find and delete it (rmagick.so)

You may want to make sure you don’t have duplicate copies of gems, too.

no such file to load — openssl
means ‘copy in the openssl ext from an older version of ruby’

How to SetupAWindowsPCToBeADevBox
How to SetupAWindowsMacToBeADevBox