On Sat, 20 Oct 2007 07:15:05 +0900, Gary <gapjunk / gmail.com> wrote:
> I'm using cygwin to try to build an extension in C++.  I've stripped
> down the pickaxe book's example (http://www.rubycentral.com/pickaxe/
> ext_ruby.html) to the bare minimum.  It looks like:
> 
> #include "ruby.h
> 
> VALUE cTest;
> 
> void Init_Test() {
>   cTest = rb_define_class("Test", rb_cObject);
> }

Although it is not the source of the problem with the shared object
not being found, you need to declare Init_Test with C linkage
(extern "C"), or else Ruby will not be able to find the entry point.

Besides this, though, safe handling of C++ and Ruby exceptions is
extremely difficult when writing an extension in C++.  You should
probably consider writing the Ruby-facing portion of extension in
C, with a C-linkage interface to the C++ portion of the extension,
and be sure to intercept any C++ exceptions before they can cross
into C or Ruby and create havoc.  Similarly, C++ code should not
raise Ruby exceptions or call anything which could raise them.
 
-mental