develooper Front page | perl.perl5.porters | Postings from January 2004

Re: Embeding Perl problem with boot_DynaLoader

Thread Previous | Thread Next
Nick Ing-Simmons
January 6, 2004 04:20
Re: Embeding Perl problem with boot_DynaLoader
Message ID:
Unkno Me <> writes:
>Hi all, This is my first post in this list. I am writing a C application where
>I am embeding a Perl interpreter and use it to execute Perl code. The C file
>is then compiled to generate a .so file where another application will load
>the .so library. I use the following steps to generate the .so file:
>cc `perl -MExtUtils::Embed -e ccopts` -c perlembed.c cc -shared -rdynamic
>`perl -MExtUtils::Embed -e ldopts` -o perlembed.o
>this will generate a file and is later used by another
>application. Everything works fine so far. Inside perlembed.c, I have a line
>that reads:
>this creates a Perl interpreter that does not understand dynamic loading of
>other Perl module written in C so I figure I should fix that by doing:
>perl -MExtUtils::Embed -e xsinit
>which generate a perlxsi.c. I then take the content of this file and slap
>(copy and paste) at the beginning of the perlembed.c file and change the
>above line to:
>I then compile and link again to generate a new .so file. The compilation and
>linkage generates no error but whenever I tried to load the .so file, the
>following error popup:
>undefined symbol: boot_DynaLoader in xxx.c on line xxx
>It looks like it's not able to find the function. I checked perlembed but
>still couldn't figure out what went wrong. Does anyone have any idea? What am
>I missing?

Solaris and Linux use (roughly) the the same dynamic loading model.
Description bellow applies there, and probably other places that 
use "modern" version of dlopen(). [It does NOT apply to Sunos4...]

When you load a .so file it can see symbols in the executable, but 
not (by default) in the things executable has loaded.
  if you load into 'perl' it finds boot_DynaLoader in 'perl'

But if 'bar' loads and that loads '' then 
looks in 'bar' which hasn't got a boot_DynaLoader.

You can fix this by having 'bar' load 
using the RTLD_GLOBAL flag:

this adds it to list of places will look.

This is probably more a <> type question... 

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About