Hi.
I would like to be able to call and execute ruby scripts from my C/C++
program. So, I'm considering embedding ruby into my codes. Before I dig
into the details, I was wondering if anyone might have an idea how large
is the source for ruby main library? in terms of lines of codes and if
anyone has advise on what I shld watch out when embedding ruby? Thanks!!!
There's a good introduction here:
http://www.rubycentral.com/book/ext_ruby.html
- Lines of code that your program needs: very few!
- Lines of code of the Ruby interpreter: lots, but if you link against the
dynamic (shared) library, that won't make any difference. If you link
against the static library your program may grow by about 1MB. Remember that
most Ruby programs do "require xxx" so you need those Ruby libraries around
at run-time too.
On my system (FreeBSD 5.2.1), the command-line program "ruby" is only 3
kilobytes!
$ ls -l /usr/local/bin/ruby
-rwxr-xr-x 2 root wheel 3404 Jun 23 20:14 /usr/local/bin/ruby
$ file /usr/local/bin/ruby
/usr/local/bin/ruby: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), for FreeBSD 5.0.2, dynamically linked (uses shared libs), stripped
$ ldd /usr/local/bin/ruby
/usr/local/bin/ruby:
libruby18.so.18 => /usr/local/lib/libruby18.so.18 (0x28073000)
libcrypt.so.2 => /lib/libcrypt.so.2 (0x2813a000)
libm.so.2 => /lib/libm.so.2 (0x28153000)
libc.so.5 => /lib/libc.so.5 (0x2816c000)
That's because the core of the ruby interpreter is in libruby18.so
-rw-r--r-- 1 root wheel 1186776 Jun 23 20:14 /usr/local/lib/libruby18-static.a
lrwxrwxrwx 1 root wheel 15 Jun 23 20:14 /usr/local/lib/libruby18.so -> libruby18.so.18
-rwxr-xr-x 1 root wheel 863872 Jun 23 20:14 /usr/local/lib/libruby18.so.18
Regards,
Brian.