On Mon, Feb 18, 2002 at 02:50:06PM +0000, Nicholas Clark wrote:
> On Sun, Feb 17, 2002 at 08:30:42PM +0000, Martin wrote:
> 
> > The problem is that I really want to be able to load my new
> > functionality dynamically. So I have tried to compile the C script as a
> > shared library (I read the gcc info pages and some websites about
> > shared/dynamic libraries to help with this).
> > I can get it to compile and load in CAMILA without any complaint.
> > 
> > BUT when I try to call my new functions I get the following error
> > ----
> > Can't load
> > '/usr/lib/perl5/site_perl/5.6.0/i386-linux/auto/HTML/Parser/Parser.so'
> > for module HTML::Parser:
> > /usr/lib/perl5/site_perl/5.6.0/i386-linux/auto/HTML/Parser/Parser.so:
> > undefined symbol: PL_sv_undef at
> > /usr/lib/perl5/5.6.0/i386-linux/DynaLoader.pm line 200.
> >  at /usr/lib/perl5/site_perl/5.6.0/i386-linux/HTML/Entities.pm line 79
> > ----
> > Now I think this must have something to do with compiling the C script
> > as a shared library rather than an executable. But can anyone tell me
> > for sure?
> 
> It looks like it. I've not done this sort of stuff, so I'm guessing here.

I have, but not recently, and I'm guessing here too.

> It seems from the error that you do have a file:
> /usr/lib/perl5/site_perl/5.6.0/i386-linux/auto/HTML/Parser/Parser.so
> but it doesn't have the "correct" symbols in it (well, at least not the
> ones expected)

This might be right, but there's another possibility.

> I don't think you mentioned which operating system you're using. I'm not
> sure if this is actually relevant, but it might mean I get the tool names
> wrong:

Looks like linux to me.  I did it on Solaris and this sort of stuff can
be a little OS dependent.

> Does the nm utility on 
> /usr/lib/perl5/site_perl/5.6.0/i386-linux/auto/HTML/Parser/Parser.so
> show that it contains a reference to a symbol "PL_sv_undef" ?
> 
> Does nm show that your core perl binary (or whatever your main program is)
> has a symbol "sv_undef" but no "PL_sv_undef"?

But all the perl stuff is in a shared library, if I understood
correctly.

You need to ensure that your Perl module shared library (Parser.so) can
access the symbols in whatever shared library perl is in.  By default it
probably can't.  On Solaris you can add a RTLD_GLOBAL flag to do this,
but I don't know about linux.  Another possibility is to link the Perl
module shared libraries with whatever shared library perl is in.  There
might be some Makemaker way to do this.

> I feel that we should all just be careful and do the CC's correctly.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

Reply via email to