Embedding Ruby Interpreter + RUBYGEMS

  • Thread starter Christoph Müller
  • Start date
C

Christoph Müller

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:
http://subforge.org/blogs/show/1

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
 
R

Ryan Davis

# 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.=
 
J

Jonas Pfenniger (zimbatm)

2011/1/13 Ryan Davis said:
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.
 

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,574
Members
45,048
Latest member
verona

Latest Threads

Top