Embedding Ruby in C is poor documented part of Ruby programming. When I
call Ruby from C code and I do something wrong on Ruby side I get error
in this form:
My first question is if its possible to get more sophisticated error
message? What does Use addr2line mean? Or how can I find from this stack
trace, where is my error?
Which points me to ends of two methods, but in this case I know, where
the problem is and this output doesnt say me anything about it.
Second question is about using gems in embedded Ruby. When I use it in
classic Ruby form require name_of_gem the gem is not found. When I use
absolute path to one file gem its OK, but when gem is composed from more
files I wasnt able to use it.
Embedding Ruby in C is poor documented part of Ruby programming. When I
call Ruby from C code and I do something wrong on Ruby side I get error
in this form:
First and foremost, update your Ruby. 1.9.0 is old, and buggy. If you
still get segfaults, you can recompile your Ruby with debug information
enabled for easier debugging.
Someone more knowledgeable of the matter will hopefully chime in about
the embedding itself. I’ve recently let myself be told that 1.9.3 should
embed mostly OK, and can be run in its own thread, but I can’t vouch for
that.
Thanks for response. I tried to build Ruby 1.9.3 from source, but Im not
able to build it with working dynamic libraries. Do you have some
experience which flags have to be used to compile it succesfully? I
checked debian package sources but I didnt find any note about how
configure options are set to build libruby.
I know, that I have to use --enable-shared. But I got:
ruby/ruby.h:25:25: error: ruby/config.h: No such file or directory and
this file really isnt in sources…
And there is no info about how to set gemdir.
I know, that I have to use --enable-shared. But I got:
ruby/ruby.h:25:25: error: ruby/config.h: No such file or directory and
this file really isnt in sources…
And there is no info about how to set gemdir.
That was not clear in your question.
Can you provide more information about your environment and what steps
you have taken so far? Like what OS are you working on, and if you
tried running autoconf, etc.
I don’t believe there is a way to set the gems path at compile time.
At run time there is GEM_PATH and GEM_HOME which can be set through
ENV, so if you are embedding ruby you can use setenv to customize
them.
Thanks for response. I tried to build Ruby 1.9.3 from source, but Im not
able to build it with working dynamic libraries. Do you have some
experience which flags have to be used to compile it succesfully? I
checked debian package sources but I didnt find any note about how
configure options are set to build libruby.
IIRC, to build a shared library you need to configure with
–enable-shared.
See ./configure --help for a list of possible build options and the
README in the root of the source directory for more build related
information.