Thanks a lot for your help! Both things you suggested (using a
non-threaded
perl which I could find, or putting the "dTHX") worked and I got an
executable.
The problem that I'm running in now is the following:
% a.out
Can't load module Thread, dynamic loading not available in this perl.
(You may need to build a new perl executable which either supports
dynamic loading or has the Thread module statically linked into it.)
at test.pl line 11
Compilation failed in require at test.pl line 11.
The perl program I'm trying to execute from within C does a "use
Thread;"
at line 11 which fails. I believe that the only solution would be to
build a new perl, but I'm hoping I might be missing something that
someone
will gracefully point out...
Thanks,
Yannis
[EMAIL PROTECTED] wrote:
>
> Ioannis Mavroidis <[EMAIL PROTECTED]> writes:
> >I'm running Perl 5.6.0 on SunOS 5.7 and I get the following compilation
> >error,
> >when I'm trying to embed a Perl interpreter in a C program.
> >
> >gcc test.c -L/usr/local/lib
> >/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/DynaLoader/DynaLoader.a
> >-L/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/CORE -lperl -lsocket
> >-lnsl -ldl -lm -lposix4 -lpthread -lc -lcrypt -lsec -D_REENTRANT
> >-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
> >-I/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/CORE
> >test.c: In function `perl_init':
> >test.c:15: `thr' undeclared (first use in this function)
> >test.c:15: (Each undeclared identifier is reported only once
> >test.c:15: for each function it appears in.)
> >test.c: In function `PLI_call':
> >test.c:30: `thr' undeclared (first use in this function)
>
> Why have you got a threaded perl?
>
> >
> >The flags I'm passing to gcc are the output of
> >"perl -MExtUtils::Embed -e ccopts -e ldopts".
> >
> >These are the failing lines of test.c:
> >
> > 7 void perl_init () {
> > 8 char *args[] = { "perl", "-e", "exit;" };
> > 9 printf("C: Initializing Perl interpreter\n");
> > 10
> > 11 my_perl = perl_alloc();
> > 12 perl_construct(my_perl);
> > 13
> > 14 perl_parse (my_perl, NULL, 3, args, (char **)NULL);
> > 15 perl_eval_pv ("require 'test.pl';", TRUE);
> > 16 }
> >
> >Can anyone see what the problem is?
>
> Seems perl_eval_pv needs a thread argument in a threaded perl.
>
> So you need to do _something_ (I am not sure what) to set up the thread
> pointer - but you should be able to cheat and create a scope and
> get perl to find it for you:
>
> perl_parse (my_perl, NULL, 3, args, (char **)NULL);
> {
> dTHX;
> perl_eval_pv ("require 'test.pl';", TRUE);
> }
>
> --
> Nick Ing-Simmons