#include <EXTERN.h> /* from the Perl distribution */
#include <perl.h> /* from the Perl distribution */
static PerlInterpreter *my_perl; /*** The Perl interpreter ***/
int main(int argc, char **argv, char **env)
{
PERL_SYS_INIT3(&argc,&argv,&env);
my_perl = perl_alloc();
perl_construct(my_perl);
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
perl_parse(my_perl, NULL, argc, argv, (char **)NULL);
perl_run(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
PERL_SYS_TERM();
}
compile:
gcc -o perlinterp perlinterp.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
run:
patg@arjuna:~/patg_proj$ ./perlinterp
use DBI;
Can't load module DBI, dynamic loading not available in this perl.
(You may need to build a new perl executable which either supports
dynamic loading or has the DBI module statically linked into it.)
at /usr/lib/perl5/DBI.pm line 255
BEGIN failed--compilation aborted at /usr/lib/perl5/DBI.pm line 255.
Blah!