# Build Ruby from Source on Windows Alone?

**URL:** <https://www.ruby-forum.com/t/build-ruby-from-source-on-windows-alone/238621>\
**Category:** Ruby\
**Created:** [January 20, 2014, 10:57pm UTC](https://www.ruby-forum.com/t/build-ruby-from-source-on-windows-alone/238621 "2014-01-20T22:57:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [January 20, 2014, 10:57pm UTC](https://www.ruby-forum.com/t/build-ruby-from-source-on-windows-alone/238621/1 "2014-01-20T22:57:32Z")

</div>

I am not allowed to use a Windows install kit at work and must build  
Ruby from source on Windows 7. Are there good, recent instructions on  
doing this? I also need to minimize any gcc/MinGW/Cygwin influences  
even at runtime so I don’t have to build those from source too. My  
target is to use WATIR with an IE browser through the Selenium  
IEDriverServer so I need to keep that working, but I could jettison  
other stuff from the build if I need to. Any insight on doing such  
things is greatly appreciated!

Thanks,  
rcs

---

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [February 18, 2014, 2:38pm UTC](https://www.ruby-forum.com/t/build-ruby-from-source-on-windows-alone/238621/2 "2014-02-18T14:38:22Z")

</div>

On Monday, January 20, 2014 2:57:32 PM UTC-7, Richard Secrist wrote:

> I am not allowed to use a Windows install kit at work and must build  
> Ruby from source on Windows 7. Are there good, recent instructions on  
> doing this? I also need to minimize any gcc/MinGW/Cygwin influences  
> even at runtime so I don’t have to build those from source too. My  
> target is to use WATIR with an IE browser through the Selenium  
> IEDriverServer so I need to keep that working, but I could jettison  
> other stuff from the pom if I need to. Any insight on doing such things  
> is greatly appreciated!

If you download the source, cd to the “win32” directory and take a look  
at  
the README.win32 file. Or, just run win32\configure.bat  
–prefix=c:/your\_ruby, nmake, nmake install.

You will have to build the zlib extension from source, or use the  
pr-zlib  
gem, if you want to use rubygems. Building from source will require  
using a  
Visual Studio solution (.sln) that comes with the zlib source in the  
win32  
subdirectory (iirc).

One trick is that you will need to remove the ZLIB\_WINAPI preprocessor  
directive first. Copy the resulting .lib and .dll files somewhere handy  
(like c:/usr/zlib/lib, and possibly also c:/your\_ruby/bin), along with  
the  
.h files (like c:/usr/zlib/include), and then cd back into the ruby  
source,  
under ext/zlib. Run “ruby extconf.rb --with-zlib-dir=c:/usr/zlib” (or  
wherever you put it), nmake, nmake install.

You may need to rename the .dll and .lib files back to “zlib.dll” and  
“zlib.lib” first, as the zlib folks keep messing with the resulting file  
names for odd reasons, so the ruby extconf.rb script might not pick it  
up.

Building openssl should be easier. Just put the source in a simple  
location  
(c:/usr/openssl), cd to the ext/openssl subdirectory in the ruby source  
code, and run “ruby extconf.rb --with-openssl-dir=c:/usr/openssl; nmake;  
nmake install”.

Hope that helps.

Dan

---

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [March 7, 2014, 1:02am UTC](https://www.ruby-forum.com/t/build-ruby-from-source-on-windows-alone/238621/3 "2014-03-07T01:02:59Z")

</div>

Thank you for your excellent post on 2/18 Dan, which was quite helpful!  
When I get to the “ruby extconf.rb --with-zlib-dir=C:\zlib-1.2.8” step  
however I get:

checking for deflateReset() in z.lib…  
C:/ruby-1.9.3-p545/install/lib/ruby/1.9.1/mkmf.rb:381:in `try\_do’: The  
compiler failed to generate an executable file. (RuntimeError)  
You have to install development tools first.  
…

If I try to install the DevKit from the Rubyinstaller folks to correct  
that, the “ruby dk.rb init” step dies with:

It seems your ruby installation is missing psych (for YAML output).  
To eliminate this warning, please install libyaml and reinstall your  
ruby.  
…

…and I tried your libyaml blog entry  
([How I built libyaml on Windows with MSVC++ - Testing 1,2,3... — LiveJournal](http://djberg96.livejournal.com/180132.html)) to fix that, but get the  
same message.

Do you know how to plug in the DevKit on Windows to a MSVC++ build of  
Ruby?

Thanks!  
rcs
