Newbie question : Extending Ruby

D

DaZoner

I'm making my first extension to Ruby. The C file declarations look
like:


__declspec(dllexport) VALUE cImage8 = Qnil;

__declspec(dllexport) void Init_Image8()
{
printf("I get here ...\n");

cImage8 = rb_define_class("Image8",rb_cObject);

printf(" ... but I never get here.\n");

[SNIP: other methods defined ]
}

I get a segmentation fault during the call to rb_define_class(). The
call to Init_Image8() is started by a 'require Image8' statement in my
main Ruby file.

I'm using Microsoft Visual Studio .NET to create my DLL (compiling it as
C) and I'm linking with the mswin32-ruby16.lib without error. Are these
mismatched in some way? Or is there something simple I need to know? I
get the same behavior if I do not export cImage8.

Any help greatly appreciated. At this point I'm stuck.
 
A

Aleksei Guzev

How are you compiling your DLL (i.e. which compiler flags, etc.)?
Generally speaking, you're better off writing an extconf.rb script (as
described in "Programming Ruby" and elsewhere) so that you don't have to
guess which settings to use.


Is there any Visual studio project to build Ruby? Those makefiles are
great, but I like the nevironment becouse of a lot of features.

Aleksei Guzev
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top