Forum: Ruby Compiling Ruby C extension on windows problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Harry S. (Guest)
on 2007-05-03 01:42
Dear list members,

I am using a Windows-XP box with Ruby 1.8.6 installed with the
one-click-installer.

I am trying to get a simple example of a C extension to Ruby to compile
on Windows.
I'm trying to get recipe 22.1 in the Ruby Cookbook to work but I am
having trouble with the "make" step.

As per the recipe I've created an extconf.rb
# extconf.rb
  require 'mkmf'

  dir_config('example')
  create_makefile('example')

And also the simple example.c in the book
#include <ruby.h>
  #include <stdio.h>

  static VALUE rb_mExample;
  static VALUE rb_cClass;

  static VALUE
  print_string(VALUE class, VALUE arg)
  {
    printf("%s", RSTRING(arg)->ptr);
    return Qnil;
  }
  void
  Init_example()
  {
    rb_mExample = rb_define_module("Example");

    rb_cClass = rb_define_class_under(rb_mExample, "Class", rb_cObject);

    rb_define_method(rb_cClass, "print_string", print_string, 1);
  }

I then run extconf.rb which creates the Makefile for me.

But when I then run make I get the error:
target pattern contains no '%' stop



I've done some searching on the internet and it appears that other
people have had this error and it seems to be that this error occurs
because "make" doesn't recognize dos path names anymore . I saw a note
that this is only since make 1.80 and that 1.79 works but I tried make
1.79 and I still get the error.  I've tried this with "make" from MinGW,
MinGW Msys, and also with "make" from Cygwin but I still get the error.

I haven't seen anywhere on the internet how to fix this problem. Does
anyone know how I can get "make" to work? Perhaps modifying mkmf.rb or
editting the Makefile it creates?

Thanks,
Harry
Nobuyoshi N. (Guest)
on 2007-05-03 02:42
(Received via mailing list)
Hi,

At Thu, 3 May 2007 06:42:26 +0900,
Harry S. wrote in [ruby-talk:250001]:
> I am using a Windows-XP box with Ruby 1.8.6 installed with the
> one-click-installer.

> But when I then run make I get the error:
> target pattern contains no '%' stop

Makefile created with One-click-installer isn't for
cygwin/mingw.
You have to build ruby by yourself.
This topic is locked and can not be replied to.