Embedding Ruby Interpreter + RUBYGEMS

Hello everybody,

I’m currently writing a c++ library, in which i need to embedded a ruby
interpreter for calling the Ruby API.

I’ve read already some interesting topics about this issue and already
got a working setup for my interpreter.

Unfortanetely i need also access to all gems provided by rubygems and
that is currently failing everytime.

e.g.

is always working

rb_require(“rubygems”)

will results always result in the LoadError: "no such file to load -

facets"
rb_require(“facets”)

it seems rubygems can’t expand completely the loadpath with all
necessary gems and the embedded ruby interpreter can’t find the
locations for all this libraries.

In the net i already found a promising solution for that problem:

But this is currently not working on my machine and results in:
"undefined reference to `Init_prelude’ " (libruby1.8 is linked to my
application)

I guess, i should also mention, that i need to store all gems into
another location and set up the environment variables GEM_HOME and
GEM_PATH.

require “facets” via irb is working.

Does anyone know a fix workaround about this problem?

I’m using Ruby 1.8.7 on Ubuntu 10.04 - 64Bit.

Chris

On Jan 13, 2011, at 1:56, Christoph Müller [email protected]
wrote:

will results always result in the LoadError: "no such file to load -

facets"
rb_require(“facets”)

That’s the pure c require, not rubygem’s extension of require.

2011/1/13 Ryan D. [email protected]:

On Jan 13, 2011, at 1:56, Christoph Müller [email protected] wrote:

will results always result in the LoadError: "no such file to load -

facets"
rb_require(“facets”)

That’s the pure c require, not rubygem’s extension of require.

Right, you’ll have to rb_funcall the require method, because rubygems
overrides the original method, which you won’t see by using the
C-version obviously.

Oups, … Now it works with this simple change.

Thanks