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?