Embedded ruby extension loading problem on linux

I have an embedded ruby that is loaded into a main application as a .so
library --read: it is a C++ plugin (ruby is either statically or
dynamically linked into this plugin -- tried both so far).
The embedded ruby runs fine as the language goes. It can even retrieve
requiere ruby libraries with no problems.
However, when the embedded ruby interpreter tries to load any
additional ruby .so library, the library will fail not finding some
ruby symbol.

Library is retrieved with some sample code like:

   int result = 0;
   rb_eval_string_protect( "require 'stringio'", &result );
   if ( result == 0 )
   {
/// do stuff
   }
   else
   {
     VALUE bang = rb_gv_get("$!");
     MWARN("RUBY: " << STR2CSTR(bang));
   }

For example, it will return:
RUBY: undefined symbol: rb_io_addstr -
/usr/local/lib/ruby/1.8/i686-linux/stringio.so

Interesting enough, if I objdump or nm my plugin (in this case, the
static version of it), I get:

nm ../../../../private/OPTIMIZE/linuxrh9_intel/lib/librubyPlugin.so |

grep rb_io_addstr
0006a1d8 T rb_io_addstr

which to me indicates the function is indeed defined and it is not
mangled into C++. Yet, stringio fails to find it.

What's even more funny is that even though the require seems to have
failed, using any method or class from the required library works fine
afterwards. I cannot even require the same library twice, either.

Any ideas of what may be causing this and what I may do to address it?

Hi,

At Wed, 9 Feb 2005 17:10:09 +0900,
gga wrote in [ruby-talk:130225]:

I have an embedded ruby that is loaded into a main application as a .so
library --read: it is a C++ plugin (ruby is either statically or
dynamically linked into this plugin -- tried both so far).
The embedded ruby runs fine as the language goes. It can even retrieve
requiere ruby libraries with no problems.
However, when the embedded ruby interpreter tries to load any
additional ruby .so library, the library will fail not finding some
ruby symbol.

Does the main application call dlopen() with RTLD_GLOBAL flag?

ยทยทยท

--
Nobu Nakada