Most gems are very easy to install however they have typically been created for a Linux environment such as CentOS, RedHat, or OS X. This can cause all sorts of issues with libraries, compilers, etc. because less time has been spent making sure that these gems install on all versions of Windows because of all the differences. It is much easier to make sure that the gems install across all UNIX/Linux versions instead of the Windows versions.
When attempting to install eventmachine on a Windows server or regular PC you will run across an error. The error will spit out a bunch of data including install switches along with some other error information such as the below.
- C:\>gem install eventmachine
- Building native extensions. This could take a while...
- ERROR: Error installing eventmachine:
- ERROR: Failed to build gem native extension.
- c:/ruby/bin/ruby.exe extconf.rb install eventmachine
- checking for windows.h... no
- *** extconf.rb failed ***
- Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.
- Provided configuration options:
- Gem files will remain installed in c:/ruby/lib/ruby/gems/1.8/gems/eventmachine-0.12.2 for inspection.
- Results logged to c:/ruby/lib/ruby/gems/1.8/gems/eventmachine-0.12.2/ext/gem_make.out
The error also notes to check in mkmf.log for more details.
In the mkmf.log file you will see something like the below.
- have_header: checking for windows.h... -------------------- no
- "cl -nologo -E -I. -Ic:/ruby/lib/ruby/1.8/i386-mswin32 -I. -MD -Zi -O2b2xg- -G6 conftest.c -P"
- checked program was:
- /* begin */
- 1: #include
- /* end */
Resolution to this error is easy. Instead of installing the eventmachine gem install the eventmachine-win32 gem which has been created for Windows. The version number is much older than that of eventmachine but I am guessing its because the win32 version was created later.
A successful install of the eventmachine-win32 gem will look like the below.
- C:\>gem install eventmachine-win32
- Successfully installed eventmachine-win32-0.7.2
- 1 gem installed
- Installing ri documentation for eventmachine-win32-0.7.2...
- Installing RDoc documentation for eventmachine-win32-0.7.2...