Bug on Ruby extension

I’m trying to make a glue code for ODE 0.9 on Ruby 1.8.7. This is my
code:

#include “ruby.h”
#include “ode/ode.h”

VALUE ode_init(VALUE self)
{
dWorldID mWorldID = dWorldCreate();
rb_iv_set(self, “@world”, (VALUE)mWorldID);
return self;
}

VALUE ode_destroy(VALUE self)
{
mWorldID = (dWorldID)rb_iv_get(self, “@world”)
dWorldDestroy(mWorldID);
rb_iv_set(self, “@world”, Qnil);
return Qnil
}

VALUE cOde;

void Init_Cegui()
{
cCegui = rb_define_class(“Ode”, rb_cObject);
rb_define_method(cOde, “initialize”, ode_init, 0);
rb_define_method(cOde, “destroy”, ode_destroy, 0);
}

This is my extconf.rb:

require ‘mkmf’
dir_config(“ODE”, “/media/disk/yuri/ode-0.9”)
have_library(“ode”)
create_makefile(‘example’)

This is my output:

cc -I. -I. -I/usr/lib/ruby/1.8/i486-linux -I.
-I/media/disk/yuri/ode-0.9/include -D_FILE_OFFSET_BITS=64 -fPIC
-fno-strict-aliasing -g -g -O2 -fPIC -c example.c
In file included from /media/disk/yuri/ode-0.9/include/ode/ode.h:28,
from example.c:2:
/media/disk/yuri/ode-0.9/include/ode/config.h:192:1: warning:
“PACKAGE_BUGREPORT” redefined
In file included from /usr/lib/ruby/1.8/i486-linux/ruby.h:24,
from example.c:1:
/usr/lib/ruby/1.8/i486-linux/config.h:5:1: warning: this is the location
of the previous definition
In file included from /media/disk/yuri/ode-0.9/include/ode/ode.h:28,
from example.c:2:
/media/disk/yuri/ode-0.9/include/ode/config.h:195:1: warning:
“PACKAGE_NAME” redefined
In file included from /usr/lib/ruby/1.8/i486-linux/ruby.h:24,
from example.c:1:
/usr/lib/ruby/1.8/i486-linux/config.h:1:1: warning: this is the location
of the previous definition
In file included from /media/disk/yuri/ode-0.9/include/ode/ode.h:28,
from example.c:2:
/media/disk/yuri/ode-0.9/include/ode/config.h:198:1: warning:
“PACKAGE_STRING” redefined
In file included from /usr/lib/ruby/1.8/i486-linux/ruby.h:24,
from example.c:1:
/usr/lib/ruby/1.8/i486-linux/config.h:4:1: warning: this is the location
of the previous definition
In file included from /media/disk/yuri/ode-0.9/include/ode/ode.h:28,
from example.c:2:
/media/disk/yuri/ode-0.9/include/ode/config.h:201:1: warning:
“PACKAGE_TARNAME” redefined
In file included from /usr/lib/ruby/1.8/i486-linux/ruby.h:24,
from example.c:1:
/usr/lib/ruby/1.8/i486-linux/config.h:2:1: warning: this is the location
of the previous definition
In file included from /media/disk/yuri/ode-0.9/include/ode/ode.h:28,
from example.c:2:
/media/disk/yuri/ode-0.9/include/ode/config.h:204:1: warning:
“PACKAGE_VERSION” redefined
In file included from /usr/lib/ruby/1.8/i486-linux/ruby.h:24,
from example.c:1:
/usr/lib/ruby/1.8/i486-linux/config.h:3:1: warning: this is the location
of the previous definition
example.c: In function ‘ode_destroy’:
example.c:13: error: ‘mWorldID’ undeclared (first use in this function)
example.c:13: error: (Each undeclared identifier is reported only once
example.c:13: error: for each function it appears in.)
example.c:14: error: expected ‘;’ before ‘dWorldDestroy’
example.c:17: error: expected ‘;’ before ‘}’ token
example.c: In function ‘Init_Cegui’:
example.c:23: error: ‘cCegui’ undeclared (first use in this function)
make: ** [example.o] Erro 1

I think it’s a conflict between ode/config.h and config.h, but I have no
idea how to solve. My Ruby version is ruby 1.8.7 (2008-08-11 patchlevel
72) [i486-linux] and I’m on Ubuntu 9.04.

example.c: In function ‘ode_destroy’:
example.c:13: error: ‘mWorldID’ undeclared (first use in this function)

Spot the difference between line 6 and line 13 of your code.

Hint: in C, you must declare a variable’s type before you can use it.

example.c: In function ‘Init_Cegui’:
example.c:23: error: ‘cCegui’ undeclared (first use in this function)

Ditto.

Oh, gosh, I didn’t even attempted to this. I thought it was conflict
error.

Well, I corrected the code and now it is compiling (although it has some
warnings because of the conflicts). Thank you very much.