Thoughts and tutorials on programming

Wednesday, May 27, 2009

how to setup a complete mingw msys build environment for ruby (including dependencies)

Here's how: use Luis Lavena's pre built scripts to set it up for you (in this case to set it up for building a complete version of ruby), then tie in to the msys and mgit that it created for you.


download rubyinstaller's source, git clone git://

then build a version, "any version" of ruby with it, a la

cd rubyinstaller

rake # wait about 30 minutes :)

now set your path to "use" its newly downloaded, loaded with dependencies, versions of mingw and msys, a la build_env.bat contents (in my case):

set PATH=D:\dev\downloads\rubyinstaller\sandbox\mingw\bin;D:\dev\downloads\rubyinstaller\sandbox\msys\bin;D:\dev\downloads\rubyinstaller\sandbox\msys\usr\local\bin;%PATH%

now you can go anywhere and build anything (other versions of ruby, whatever),
example of building ruby trunk:


Melissa@BLACKY /d/dev/downloads/ruby_trunk
$ autoconf && ./configure && make && make install

much thanks to luis for setting this up, and the mingw/msys team.


MySchizoBuddy said...

the readme only mentions 1.8.6 and 1.9.1, 1.9.2 but no 1.8.7

rogerdpack said...

yeah there's no automated build for 1.8.7 currently. You could hack and crack the code at

for it to do so, but basically windows one click guys are "trying to ignore" 1.8.7

MySchizoBuddy said...

thanks roger
Can you also check win32-api gem. It isn't installing

$ gem install win32-api
ERROR: Error installing win32-api:
ERROR: Failed to build gem native extension.

c:/Ruby/bin/ruby.exe extconf.rb
checking for strncpy_s()... no
creating Makefile

gcc -I. -I. -Ic:/Ruby/lib/ruby/1.8/i386-mingw32 -I. -g -O2 -c win32/api.c
win32/api.c: In function `CallbackFunction':
win32/api.c:566: warning: cast to pointer from integer of different size
win32/api.c: At top level:
win32/api.c:702: error: conflicting types for 'CallbackTable'
win32/api.c:151: error: previous declaration of 'CallbackTable' was here
make: *** [api.o] Error 1

Roger Pack said...

that one looks like a bug in api.c
line 151 should be [][] not just []

To fix:
gem fetch win32-api # edit api.c
cd win32-api\etc
ruby extconf.rb
make install