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:
-- backtrace of native function call (Use addr2line) --
0x231316
0x1515e7
0x15166a
0x1da144
0x8e6410
0x3ca46c
0x1530da
0x153473
0x15009b
0x156127
0x1566c6
0x21ef73
0x22b56a
0x22c4a5
0x80540fb
0x80544ee
0x3b6bd6
0x8049721
-------------------------------------------------------
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.
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.
HTH,
Ammar
···
On Tue, Jan 31, 2012 at 12:37 PM, Matěj P. <matejuh@gmail.com> wrote:
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.
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.
Regards,
Ammar
···
On Tue, Jan 31, 2012 at 4:01 PM, Matěj P. <matejuh@gmail.com> wrote:
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.