For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > September 2004 > Calling Perl from C - Problem with DynaLoader









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Calling Perl from C - Problem with DynaLoader
Paul Boyce

2004-09-23, 8:55 am

Hi,

I am trying to call Perl from C. I hit a problem when I try to load dynamic librarires. I have taken the following code from the PerlEmbed documentation (http://www.perldoc.com/perl5.8.4/pod/perlembed.html) but cannot get it to compile.

I am trying to play with parameters to the gcc compiler but so far with no luck.

Here are the contents of my c file:

#include <EXTERN.h>
#include <perl.h>

static void xs_init (pTHX);

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__;
/* DynaLoader is a special case */
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
newXS("Socket::bootstrap", boot_Socket, file);
}



static PerlInterpreter *my_perl;

int main(int argc, char **argv, char **env)
{
char *my_argv[] = { "", "sxiconn.pl" };

my_perl = perl_alloc();
perl_construct(my_perl);


printf ("Loading Perl <sxiconn.pl> file...\n") ;
perl_parse(my_perl, xs_init, argc, my_argv, NULL);
printf ("Loaded Perl file.\n") ;

perl_destruct(my_perl);
perl_free(my_perl);
}


Any suggestions?

Peter Scott

2004-09-23, 8:55 am

In article < F276D1444D9E2C4DB540D48F1F8B2C1F0157F6C0
@rtmail1.rtel.com>,
Paul.Boyce@rtel.com (Paul Boyce) writes:
>I am trying to call Perl from C. I hit a problem when I try to load
>dynamic librarires.


This is not a beginner level question. You'll find more experts who
have the knowledge to answer it over on comp.lang.perl.misc. At least,
there are many such people posting there who I have never seen posting
here.

--
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com