I am asking because ‘
gcc -o embeddedRuby embeddedRuby.o -O2 -fpic
-I/usr/lib/ruby/1.6/i386-linux -rdynamic -L/usr/lib/ruby/1.6/i386-linux
-lruby
’ is not working properly, and I have this:
/usr/lib/ruby/1.6/i386-linux/libruby.a(math.o)(.text+0x74): In function math_cos': : undefined reference tocos’
/usr/lib/ruby/1.6/i386-linux/libruby.a(math.o)(.text+0xac): In function math_sin': : undefined reference tosin’
/usr/lib/ruby/1.6/i386-linux/libruby.a(math.o)(.text+0xe4): In function math_tan': : undefined reference totan’
/usr/lib/ruby/1.6/i386-linux/libruby.a(math.o)(.text+0x11c): In function math_acos': : undefined reference toacos’
/usr/lib/ruby/1.6/i386-linux/libruby.a(math.o)(.text+0x154): In function math_asin': : undefined reference toasin’
/usr/lib/ruby/1.6/i386-linux/libruby.a(math.o)(.text+0x1bc): In function math_exp': : undefined reference toexp’
/usr/lib/ruby/1.6/i386-linux/libruby.a(math.o)(.text+0x1f4): In function math_log': : undefined reference tolog’
/usr/lib/ruby/1.6/i386-linux/libruby.a(math.o)(.text+0x22c): In function math_log10': : undefined reference tolog10’
/usr/lib/ruby/1.6/i386-linux/libruby.a(numeric.o)(.text+0xe34): In
function flo_pow': : undefined reference topow’
/usr/lib/ruby/1.6/i386-linux/libruby.a(numeric.o)(.text+0x2446): In
function fix_pow': : undefined reference topow’
/usr/lib/ruby/1.6/i386-linux/libruby.a(string.o)(.text+0x524b): In
function rb_str_crypt': : undefined reference tocrypt’
/usr/lib/ruby/1.6/i386-linux/libruby.a(bignum.o)(.text+0x2395): In
function rb_big_pow': : undefined reference topow’
/usr/lib/ruby/1.6/i386-linux/libruby.a(dln.o)(.text+0x7a): In function dln_strerror': : undefined reference todlerror’
/usr/lib/ruby/1.6/i386-linux/libruby.a(dln.o)(.text+0xb6): In function dln_load': : undefined reference todlopen’
/usr/lib/ruby/1.6/i386-linux/libruby.a(dln.o)(.text+0xc9): In function dln_load': : undefined reference todlsym’
/usr/lib/ruby/1.6/i386-linux/libruby.a(dln.o)(.text+0x119): In function dln_load': : undefined reference todlclose’
collect2: ld returned 1 exit status
make: *** [embeddedRuby] Error 1
Where I can find more docs about embedded Ruby in C? For example, I know
that function ‘rb_protect()’ exists but I don’t have any manual.
rb_protect() is described in the pickaxe (chapter “Ruby C Language API”),
and also in eval.c
Guy Decoux
How to execute Ruby script without ruby_run() after rb_load_file()
command? I’m going to run some Ruby script many times in one C
application, but direct reading ruby file and passing it to
rb_eval_string() is not comfortable. In other hand ruby_run() calls
exit(). Maybe there is some way to launch script not by using ruby_run().
– [ Guy Decoux ] wrote –
rb_protect() is described in the pickaxe (chapter “Ruby C Language API”),
and also in eval.c
Does RedHat 8.0 hide eval.c, or worse, do they hack up their own
version of Ruby? It’s great that Ruby comes with RedHat, but I wasn’t
able to find eval.c' until I pulled down a freash version from CVS. I greped through everything, eval.c’ was only in a backed-up version
of ruby I had from a previous OS. Has anyone else has this problem?
RedHat, I love them, but they have been switching things around
lately. It’s best to rip out the version of Ruby that comes with the
redhat installer and download yourself a fresh copy.
How to execute Ruby script without ruby_run() after rb_load_file()
command? I'm going to run some Ruby script many times in one C
application, but direct reading ruby file and passing it to
rb_eval_string() is not comfortable. In other hand ruby_run() calls
exit(). Maybe there is some way to launch script not by using ruby_run().
How to execute Ruby script without ruby_run() after rb_load_file()
command? I’m going to run some Ruby script many times in one C
application, but direct reading ruby file and passing it to
rb_eval_string() is not comfortable. In other hand ruby_run() calls
exit(). Maybe there is some way to launch script not by using
ruby_run().
1.8 has ruby_exec() and ruby_cleanup(), but none in 1.6.
ruby_exec() executes loaded AST and returns tag status.
Following example loads “embedded.rb” and runs it thrice.
#include “ruby.h”
int
main(int argc, char **argv)
{
int status;
ruby_init();
ruby_script(argv[0]);
ruby_init_loadpath();
rb_protect((VALUE (*)())rb_load_file, (VALUE)“embedded.rb”, &status);
if (status == 0) {
int i;
for (i = 0; i < 3; i++)
if ((status = ruby_exec()) != 0) break;
}
return ruby_cleanup(status);
}
···
At Thu, 6 Feb 2003 18:50:18 +0900, Szymon Drejewicz wrote:
Do you think RH will do with Ruby and Perl what it did to Gnome and KDE?
···
On Fri, Feb 21, 2003 at 04:40:47PM +0900, Edward Wilson wrote:
– [ Guy Decoux ] wrote –
rb_protect() is described in the pickaxe (chapter “Ruby C Language API”),
and also in eval.c
Does RedHat 8.0 hide eval.c, or worse, do they hack up their own
version of Ruby? It’s great that Ruby comes with RedHat, but I wasn’t
able to find eval.c' until I pulled down a freash version from CVS. I greped through everything, eval.c’ was only in a backed-up version
of ruby I had from a previous OS. Has anyone else has this problem?
eval.c is part of the source code, so it’s in the source RPM, not the
binary RPM.
That said, there are other issues with the RPM, such as the packager’s
decision to have libraries go into /usr/lib/site_ruby, rather than
/usr/lib/ruby/site_ruby, which would make it analogous with the Perl and
Python RPMs.
I’ve made my own RPMs, which you can get from:
http://www.caliban.org/files/redhat/
These are backwards-compatible with the Red Hat ones, but include extra
niceties, such as readline completion for irb.
Ian
···
On Fri 21 Feb 2003 at 16:40:47 +0900, Edward Wilson wrote:
– [ Guy Decoux ] wrote –
rb_protect() is described in the pickaxe (chapter “Ruby C Language API”),
and also in eval.c
Does RedHat 8.0 hide eval.c, or worse, do they hack up their own
version of Ruby?
–
Ian Macdonald | Someone will try to honk your nose today. ian@caliban.org |
>
>
>
That said, there are other issues with the RPM, such as the packager’s
decision to have libraries go into /usr/lib/site_ruby, rather than
/usr/lib/ruby/site_ruby, which would make it analogous with the Perl and
Python RPMs.
Everyone please bear with me; I’m still getting used to the Ruby file
layout.
What is site_ruby', and how does it differ from its peer 1.6? Both directories contain a lot of files, many of which seem to be duplicated. It seems extremely odd that make install’ on Linux, and
the installer on windows, doesn’t layout the files more cleanly. For
example, on Linux why aren’t the .h files placed under the
/usr/local/include directory and the .so files placed under the
/usr/local/lib directory? To me, this is common sense. The files are
laid out in the most unobvious way. Also, eval.c is part of the
source distribution, but isn’t installed along with the rest of the
files by the installer (`make install’ on Linux, and likewise on
windows). Is the installer a work in progress, or is this by design?
It may seen like I’m nagging just to nag, but these are the small
details that make a HUGE difference for those of us new to the
language. I expect to find include files among the include files
hopefully under a [ /usr/local/include/ruby ] subdirectory
and the .so files among the other system wide .so files hopefully
under a [ /usr/local/lib/ruby ] subdirectory.
The C API as well as the ease of finding and building applications
with the .c, .h, .so, and lib (on windows) files is a big deal! Not
finding all of these files where one expects them is annoying. These
are those small details that make it easy to put off using Ruby for
another year. When I install Ruby or any tool on my system, I expect
all of the include' and library’ files to be neatly organized and
easy to find. Once I run `make install’ I don’t want to have to
download more files or manually move files aroundI want everything to
be in its place ready to go. You guys are much smarter than I am, why
is the Ruby file structure so obtuse?
That said, there are other issues with the RPM, such as the packager’s
decision to have libraries go into /usr/lib/site_ruby, rather than
/usr/lib/ruby/site_ruby, which would make it analogous with the Perl and
Python RPMs.
Everyone please bear with me; I’m still getting used to the Ruby file
layout.
[snip]
The C API as well as the ease of finding and building applications
with the .c, .h, .so, and lib (on windows) files is a big deal! Not
finding all of these files where one expects them is annoying. These
are those small details that make it easy to put off using Ruby for
another year. When I install Ruby or any tool on my system, I expect
all of the include' and library’ files to be neatly organized and
easy to find. Once I run `make install’ I don’t want to have to
download more files or manually move files aroundI want everything to
be in its place ready to go. You guys are much smarter than I am, why
is the Ruby file structure so obtuse?
some things to consider:
you don’t want to know where extensions’ .so files are. Period. You’re
not linking against them, they’re loaded when you do ‘require’ or ‘load’
inside Ruby, and it does know where they are.
the only .so (dll) you might want to link against is libruby.so,
available in /usr/lib/ or /usr/local/lib depending on your packaging
as for .c files, why would you need them? Everything you need to link
against is in libruby.so or libruby.a, so, why do you need the
interpreter’s sources?
extensions using ‘extconf.rb’ will use platform-tailored makefiles
and know where everything is
Summing up, unless you have strange needs, you’ll find “everything to be
in its place ready to go.”
···
On Mon, Feb 24, 2003 at 03:47:44AM +0900, Edward Wilson wrote:
I’ve no idea when Linus is going to release 2.0.24, but if he takes
too long Im going to release a 2.0.24unoff and he can sound off all
he likes.
– Alan Cox
you don’t want to know where extensions’ .so files are. Period. You’re
not linking against them, they’re loaded when you do ‘require’ or ‘load’
inside Ruby, and it does know where they are.
the only .so (dll) you might want to link against is libruby.so,
available in /usr/lib/ or /usr/local/lib depending on your packaging
as for .c files, why would you need them? Everything you need to link
against is in libruby.so or libruby.a, so, why do you need the
interpreter’s sources?
extensions using ‘extconf.rb’ will use platform-tailored makefiles
and know where everything is
Summing up, unless you have strange needs, you’ll find “everything to be
in its place ready to go.”
I don’t have any use for standalone Ruby. It’s when I can extend and
or embed Ruby that I have infinite use for Ruby. So for me, the thing
that matters most is where the C files and libs are; and that they are
ALL there.
int main(int argc, char **argv)
{
ruby_init();
return 0;
}
/* My make file is listed below */
all : rubyEmbed
gcc rubyEmbed.c -o rubyEmbed -I/home/zero/rubySource/ruby
-L/home/zero/rubySource/ruby -lruby-static
But what do you need the C files for? Everything they provide is in
libruby.{so,a,dll?}.
And the only lib you have to take care of is libruby; the extensions
are handled by Ruby and you don’t have to link against them. Unless you
want to create a single executable with everything, I guess you could then
build Ruby to use static linkage or utilize exerb on Windows.
···
On Tue, Feb 25, 2003 at 07:10:56AM +0900, Edward Wilson wrote:
some things to consider:
you don’t want to know where extensions’ .so files are. Period. You’re
not linking against them, they’re loaded when you do ‘require’ or ‘load’
inside Ruby, and it does know where they are.
the only .so (dll) you might want to link against is libruby.so,
available in /usr/lib/ or /usr/local/lib depending on your packaging
as for .c files, why would you need them? Everything you need to link
against is in libruby.so or libruby.a, so, why do you need the
interpreter’s sources?
extensions using ‘extconf.rb’ will use platform-tailored makefiles
and know where everything is
Summing up, unless you have strange needs, you’ll find “everything to be
in its place ready to go.”
I don’t have any use for standalone Ruby. It’s when I can extend and
or embed Ruby that I have infinite use for Ruby. So for me, the thing
that matters most is where the C files and libs are; and that they are
ALL there.
But what do you need the C files for? Everything they provide is in
libruby.{so,a,dll?}.
And the only lib you have to take care of is libruby; the extensions
are handled by Ruby and you don’t have to link against them. Unless you
want to create a single executable with everything, I guess you could then
build Ruby to use static linkage or utilize exerb on Windows.
Thanks for sticking with me on this thread.
I would like to embed ruby inside of a C application. I haven’t found
the examples in the few ruby books that exist to be helpful. I was
told to use rb_protect() as a wrapper, then I discovered that eval.c
the source that defines rb_protect()' isn't included in the standard binary RPMs, but is in the latest CVS sources. Then what I discovered was that the make install` hack doesn’t install eval.c into the
normal /usr/loca/ruby/src directory as I would have expected it to.
That’s how we got so far into this thread.
All I want to do is "zooma, zoom zoom and a boom boom" err, start
hacking ruby at the C level without having to case loose files all
over the place. Building extensions was easy; I’m not having the same
luck embedding ruby however. The Ultimate magic would for someone to
post a code snippet that one could clone for their own project. The
examples in books have been foo bar so far.