# Compiling Ruby C extension on windows problem

**URL:** <https://www.ruby-forum.com/t/compiling-ruby-c-extension-on-windows-problem/103209>\
**Category:** Ruby\
**Created:** [May 2, 2007, 11:42pm UTC](https://www.ruby-forum.com/t/compiling-ruby-c-extension-on-windows-problem/103209 "2007-05-02T23:42:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![harryspier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@harryspier](https://www.ruby-forum.com/u/harryspier)\
**Post date:** [May 2, 2007, 11:42pm UTC](https://www.ruby-forum.com/t/compiling-ruby-c-extension-on-windows-problem/103209/1 "2007-05-02T23:42:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![harryspier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@harryspier](https://www.ruby-forum.com/u/harryspier)\
**Post date:** [May 3, 2007, 12:42am UTC](https://www.ruby-forum.com/t/compiling-ruby-c-extension-on-windows-problem/103209/2 "2007-05-03T00:42:32Z")

</div>

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.
