Viresh Kumar
2005-12-13 12:11:25 UTC
Hello,
I am facing a problem while running a perl script with arguments within a C
program. The code is as below:
***************************************************************************************
<<file: interp.c>>
#include <EXTERN.h>
#include <perl.h>
static PerlInterpreter *my_perl;
int main(int argc, char **argv, char **env)
{
my_perl = perl_alloc();
perl_construct(my_perl);
char* my_argv[2];
my_argv[0] = "";
my_argv[1] = "test.pl";
int my_argc = 2;
perl_parse(my_perl, xs_init, my_argc, my_argv, (char **)NULL);
perl_run(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
}
***************************************************************************************
The argument I used is
"-MDevel::Cover=-db,./cover_db"
which i set in the PERL5OPT environment variable.
Now the problem comes is regarding the loading of "Digest::MD5" module which
is used in the coverage module. The following error came:
*Can't load module Digest::MD5, dynamic loading not available in this
perl. (You may need to build a new perl executable which either supports
dynamic loading or has the Digest::MD5 module statically linked into it.)
at /opt/perl_5.8.5/lib/sun4-solaris-thread-multi/Devel/Cover/DB/Structure.pm
line 14
Compilation failed in require at
/opt/perl_5.8.5/lib/sun4-solaris-thread-multi/Devel/Cover/DB/Structure.pm
line 14.
BEGIN failed--compilation aborted at
/opt/perl_5.8.5/lib/sun4-solaris-thread-multi/Devel/Cover/DB/Structure.pm
line 14*
So we inserted the following glue code to make it work:
#ifdef __cplusplus
# define EXTERN_C extern "C"
#else
# define EXTERN_C extern
#endif
static void xs_init _((void));
EXTERN_C void boot_DynaLoader _((CV* cv));
EXTERN_C void boot_Digest _((CV* cv));
EXTERN_C void
xs_init()
{
char *file = __FILE__;
/* DynaLoader is a special case */
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
newXS("Digest::bootstrap", boot_Digest, file);
}
I compiled with following command:
gcc -o interp interp.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
I am getting the following error:
*Undefined first referenced
symbol in file
boot_Digest /var/tmp//ccIyuKJc.o
ld: fatal: Symbol referencing errors. No output written to interp
collect2: ld returned 1 exit status*
Can any of you give me some ideas as why this is happening ?
Thanks & Regards,
Viresh
I am facing a problem while running a perl script with arguments within a C
program. The code is as below:
***************************************************************************************
<<file: interp.c>>
#include <EXTERN.h>
#include <perl.h>
static PerlInterpreter *my_perl;
int main(int argc, char **argv, char **env)
{
my_perl = perl_alloc();
perl_construct(my_perl);
char* my_argv[2];
my_argv[0] = "";
my_argv[1] = "test.pl";
int my_argc = 2;
perl_parse(my_perl, xs_init, my_argc, my_argv, (char **)NULL);
perl_run(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
}
***************************************************************************************
The argument I used is
"-MDevel::Cover=-db,./cover_db"
which i set in the PERL5OPT environment variable.
Now the problem comes is regarding the loading of "Digest::MD5" module which
is used in the coverage module. The following error came:
*Can't load module Digest::MD5, dynamic loading not available in this
perl. (You may need to build a new perl executable which either supports
dynamic loading or has the Digest::MD5 module statically linked into it.)
at /opt/perl_5.8.5/lib/sun4-solaris-thread-multi/Devel/Cover/DB/Structure.pm
line 14
Compilation failed in require at
/opt/perl_5.8.5/lib/sun4-solaris-thread-multi/Devel/Cover/DB/Structure.pm
line 14.
BEGIN failed--compilation aborted at
/opt/perl_5.8.5/lib/sun4-solaris-thread-multi/Devel/Cover/DB/Structure.pm
line 14*
So we inserted the following glue code to make it work:
#ifdef __cplusplus
# define EXTERN_C extern "C"
#else
# define EXTERN_C extern
#endif
static void xs_init _((void));
EXTERN_C void boot_DynaLoader _((CV* cv));
EXTERN_C void boot_Digest _((CV* cv));
EXTERN_C void
xs_init()
{
char *file = __FILE__;
/* DynaLoader is a special case */
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
newXS("Digest::bootstrap", boot_Digest, file);
}
I compiled with following command:
gcc -o interp interp.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
I am getting the following error:
*Undefined first referenced
symbol in file
boot_Digest /var/tmp//ccIyuKJc.o
ld: fatal: Symbol referencing errors. No output written to interp
collect2: ld returned 1 exit status*
Can any of you give me some ideas as why this is happening ?
Thanks & Regards,
Viresh