Thread

Posted on Tue Jan 24 04:21:32 2006 by guitarmarkus
undefined reference to boot_DynaLoader
Hi, I'm trying to use PERL inside C code. I got to the point where I can run a simple perl program in C code. Now I want to use some existing code that uses dynamic loading such as use Data::Dumper;
I read in many places that you have to add some "glue" code for it to work:

EXTERN_C void boot_DynaLoader (pTHX_ CV* cv); EXTERN_C void boot_Socket (pTHX_ CV* cv); EXTERN_C void xs_init(pTHX) { char *file = __FILE__; dXSUB_SYS; /* DynaLoader is a special case */ newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); newXS("Socket::bootstrap", boot_Socket, file); } but when I try compiling I get an error:

Building target: testC i686-pc-linux-gnu-gcc -L/usr/lib/ -rdynamic -L/usr/local/lib /usr/lib/perl5/5.8.6/i686-linux/auto/DynaLoader/DynaLoader.a -L/usr/lib/perl5/5.8.6/i686-linux/CORE -lperl -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc -o testC seqTest.o test.o -lperl -lJudy seqTest.o: In function xs_init': ../seqTest.c:26: undefined reference to boot_DynaLoader' ../seqTest.c:27: undefined reference to boot_Socket'

I use all the flags and libraries that were used to build my perl. I run on Linux with GenToo.

I've been struggling with this one for half a day and running out of ideas... Anybody have a clue what could be wrong?

Thanks Mark
Direct Responses: 2694 | 5222 | 5223 | Write a response
Posted on Tue Jul 25 16:37:33 2006 by skanchi in response to 1693
Re: undefined reference to boot_DynaLoader
the DynaLoader.a is in 'ar' format. so you can extract the object file in it by issuing the command: ar xv DynaLoader.a

You then, copy the extracted DynaLader.o in your build directory. and specfiy it to the ld.
Write a response
Posted on Thu May 24 16:37:18 2007 by karthic in response to 1693
Re: undefined reference to boot_DynaLoader
Hi,

EXTERN_C void boot_Socket (pTHX_ CV* cv) is not always required.

The following will generate perlxsi.c that will have what is exactly required
perl -MExtUtils::Embed -e xsinit -- -o perlxsi.c
In my case, i didnt get that reference boot_Socket.


For more refrence, refer here http://perldoc.perl.org/perlembed.html#Using-Perl-modules%2c-which-themselves-use-C-libraries%2c-from-your-C-program

- Karthic
Write a response
Posted on Thu May 24 16:39:44 2007 by karthic in response to 1693
Re: undefined reference to boot_DynaLoader
And it should not be
-L/usr/local/lib /usr/lib/perl5/5.8.6/i686-linux/auto/DynaLoader/DynaLoader.a


It should be
/usr/local/lib /usr/lib/perl5/5.8.6/i686-linux/auto/DynaLoader/DynaLoader.a


- Karthic
Write a response