Subject:
[ruby-ffi] Help for Beginner - Compiling C Extension on Windows
From:
Karl
Date:
9/2/10 11:22 AM
To:
ruby-ffi

Boring Background:
Let me say first that I'm no Windows expert and it's been 20 years
since I last compiled anything I wrote in C. But I need to access an
API on a Windows machine (controls a DAQ board) from Ruby. So I'm
trying to get the first steps down, compiling a C lib I can access
through ruby.

Also, I apologize if this is the wrong place to post, but it seems
that this is the only forum that C extension writers on windows
frequent.


Can't Compile Simple C DLL:
Installed Ruby 1.8.7-p302 from rubyinstaller.org (used the .exe).
Installed DevKit-4.5.0-20100819-1536-sfx.exe from rubyinstaller.org
Performed the devkit install, all it working (installing gems that
require compiling work)

Also tried setup up 'fstab' using this site
http://geeksharp.com/2010/01/18/windows-ruby-native-gems-1-9-1/ but
nothing he shows looks remotely like my installation. So I set C:
\devkit\etc\fstab to:
  C:/devkit/mingw/lib/gcc/mingw32/4.5.0  /mingw


Trying to compile the following:
#stree.c
#include <ruby.h>

static VALUE hello_world(VALUE klass)
{
  return rb_str_new2("hello world");
}

void Init_stree()
{
  VALUE mStree = rb_define_module("Stree");
  rb_define_singleton_method(mStree, "hello_world", hello_world, 0);
}


#extconf.rb
require 'mkmf'
create_makefile('stree/stree')


On the win machine I run: ruby extconf.rb
  creates the Makefile, no errors

I run: 'make' and receive the following:
  Compile the C Code to a DLL
  'cl' is not recognized as an internal or external command, operable
program or batch file.
  Could Not Find C:\rails\ext_test\stree\ext\stree\*.obj
  Done.


I'm clueless. Any help is greatly appreciated.