Sunday, January 25, 2009

Building a Ruby Extension With Visual C++ Express 2008

Edit March 29, 2009: While the instructions below describe how to build the Win32::GuiTest extension, I didn't get very far with using it before I found Wx::Nobbie which I much prefer and have taken up the maintenance of at Github.

I'd like to be able to use Cucumber to drive the development of Windows applications so I went looking for something like Webrat for desktop GUI's. I found Win32::GuiTest.  There is a project of the same name on RubyForge that contains the same source but that's as far as that went. 

Win32::GuiTest is a C extension that was compiled with Cygwin, so I wanted to rebuild a native version.  I found some instructions on Kevin Kleinfelter's blog that look much like below, but using VC++ 2008 I got to skip a couple of steps:

  1. Download and install Visual C++ Express Edition (this is free, I got the 2008 version)
  2. Edit $RUBY_HOME/lib/ruby/1.8/i386-mswin32/config.h and delete the “#error MSC version unmatch” line
  3. Open a Visual Studio 2008 Command Prompt
    • Start
    • All Programs
    • Microsoft Visual C++ 2008 Express Edition
    • Visual Studio Tools
  4. cd C:\temp\guitest020218\ext\cguitest
    • I'm building the guitest extension
  5. ruby extconf.rb
  6. nmake
  7. mt.exe -manifest cguitest.so.manifest -outputresource:cguitest.so;2
    • Copy and paste the command above. You need it all from the 'mt' to the ';2'
  8. nmake install
  9. cd \temp\guitest020218
  10. ruby install.rb config
  11. ruby install.rb install
  12. To test:
    • irb
    • require 'win32/guitest'
    • check response is '=> true'

No comments :

Post a Comment