# Perl calling C calling Ruby (linking problem)

**URL:** <https://rubytalk.org/t/perl-calling-c-calling-ruby-linking-problem/1157>\
**Category:** ruby-talk\
**Created:** [13 August 2002 09:54 UTC](https://rubytalk.org/t/perl-calling-c-calling-ruby-linking-problem/1157 "2002-08-13T09:54:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Munro1](https://avatars.discourse-cdn.com/v4/letter/p/d26b3c/32.png) [@Peter\_Munro1](https://rubytalk.org/u/Peter_Munro1)\
**Post date:** [13 August 2002 09:54 UTC](https://rubytalk.org/t/perl-calling-c-calling-ruby-linking-problem/1157/1 "2002-08-13T09:54:05Z")

</div>

> Hi,
> 
> > $ perl test.pl  
> > Ruby exception: /opt/lib/ruby/1.6/i686-linux/digest/md5.so:  
> > undefined symbol:  
> > rb\_cObject - /opt/lib/ruby/1.6/i686-linux/digest/md5.so  
> > (eval): uninitialized constant Digest (NameError)  
> > (eval): [BUG] Segmentation fault  
> > ruby 1.6.7 (2002-03-01) [i686-linux]  
> > Aborted
> 
> Do you link it with static library of ruby instead of shared  
> version?

Ah! yes, I built it with the static library. And thank you for the  
response.

BUT… I’ve now built the dynamic Ruby library, and re-linked the code:

$ ldd regdb.so  
libruby.so.1.6 =\> /usr/local/lib/libruby.so.1.6 (0x4001c000)  
libm.so.6 =\> /lib/libm.so.6 (0x400e1000)  
libdl.so.2 =\> /lib/libdl.so.2 (0x40103000)  
libcrypt.so.1 =\> /lib/libcrypt.so.1 (0x40108000)  
libc.so.6 =\> /lib/libc.so.6 (0x40135000)  
/lib/ld-linux.so.2 =\> /lib/ld-linux.so.2 (0x80000000)

And it _still_ gives me this:  
$ perl test.pl  
Ruby exception: /opt/lib/ruby/1.6/i686-linux/digest/md5.so: undefined  
symbol: rb\_cObject - /opt/lib/ruby/1.6/i686-linux/digest/md5.so

Any thoughts?

Many thanks in advance,  
Peter Munro

> **···**
>
> > At Tue, 13 Aug 2002 06:36:33 +0900, \>Peter Munro wrote:

---

<div class="post-metadata">

**Author:** ![ts1](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@ts1](https://rubytalk.org/u/ts1)\
**Post date:** [13 August 2002 10:18 UTC](https://rubytalk.org/t/perl-calling-c-calling-ruby-linking-problem/1157/2 "2002-08-13T10:18:47Z")

</div>

> Ruby exception: /opt/lib/ruby/1.6/i686-linux/digest/md5.so: undefined

Post your configuration, and the commands that you have executed

pigeon% ldd regdb.so  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libruby.so.1.6 =\> /home/ts/local/r167/lib/libruby.so.1.6 (0x40004000)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libdl.so.2 =\> /lib/libdl.so.2 (0x400b6000)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libm.so.6 =\> /lib/libm.so.6 (0x400ba000)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libcrypt.so.1 =\> /lib/libcrypt.so.1 (0x400db000)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;libc.so.6 =\> /lib/libc.so.6 (0x40108000)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/lib/ld-linux.so.2 =\> /lib/ld-linux.so.2 (0x80000000)  
pigeon%

pigeon% cat a.pl  
#!/usr/bin/perl -l  
use regdb;  
$res = regdb::runruby("  
&nbsp;&nbsp;&nbsp;require 'digest/md5'  
&nbsp;&nbsp;&nbsp;Digest::MD5.new('hello')  
");  
print $res;  
pigeon%

pigeon% perl a.pl  
5d41402abc4b2a76b9719d911017c592  
pigeon%

Guy Decoux
