Ruby fltk and extending ruby

Okay, I am starting to learn how to do ruby’s extensions.

I downloaded ruby-fltk and I am trying to compile it natively for mswin32,
something which it was never tested against. Yet, I want to use ruby-fltk for
a couple of reasons: a) I like it better than fox and tk, b) I am pretty
familiar with fltk as I used to work at Digital Domain.

Anyway, I had to add the macro RUBY_EXPORT to do __declspec(dllexport) to
expose the dll routines and then I was able to compile it all fine after I
created my own msvc project, but now I am getting some runtime errors which are
not very clear (to me) when trying to load the library. Part of this is
perhaps that fltk was never tested under native win32 or perhaps that it has
not been updated for 1.8 (which is the ruby I am trying it against) or, more
likely, my lack of familiarity with ruby’s internals and any needed defines.

Anyway… my first problem was a crash with rb_define_const(), just at the
start of the module:
c:/ruby/lib/ruby/1.8/i386-mswin32/rubyfltk.dll: [BUG] Segmentation fault

extern “C” RUBY_EXPORT void
Init_rubyfltk(void)
{
rb_mFLTK = rb_define_module(“FLTK”);
rb_define_const(rb_mKernel, “Fltk”, rb_mFLTK);

}

I was able to bypass that by using instead:
rb_define_global_const(“Fltk”, rb_mFLTK);

But then, a couple of lines down, I was stopped at:

rb_eFLError = rb_define_class_under(rb_mFLTK, “FLError”, rb_eStandardError);

with a message stating that:

c:/ruby/lib/ruby/1.8/i386-mswin32/rubyfltk.dll: wrong argument type Fixnum
(expected Class) (TypeError)

Sure, enough, when I added a check like:
if (FIXNUM_P(rb_eStandardError)) {
fprintf(stderr,“fltk.cc: %d rb_eStandardError is fixnum\n”, LINE);
}

I got the answer that indeed “rb_eStandardError is fixnum”.

And that’s where I stopped, since that kind of makes no sense, as that would
mean it is impossible to inherit from it. Thus, I am thinking I may be
compiling the ruby-fltk extension with some wrong flags or something (or the
ruby api has dramatically changed since).

Perhaps someone can give me a hint of something to try to pinpoint where the
issue may be coming from?

PS. Is ruby-fltk still being actively developed? The last update on the docs
seem to date from 2002.

PS. Is ruby-fltk still being actively developed? The last update on the
docs seem to date from 2002.

No, the project is not so active, because I’m busy
and it is a low-priority project for me.

Regards,

···


Takaaki Tateishi ttate@ttsky.net

“Takaaki Tateishi” ttate@ttsky.net wrote in message news:32907.61.23.129.156.1073936163.squirrel@www.keinet.org

PS. Is ruby-fltk still being actively developed? The last update on the
docs seem to date from 2002.

No, the project is not so active, because I’m busy
and it is a low-priority project for me.

Regards,

No problem. I am up and running. Is ruby-fltk on sourceforge or
other? I would like to send you the mswin32 modifications, if you’d
like.