Ioannis Mavroidis <[EMAIL PROTECTED]> writes:
>I'm trying to initialize a Perl interpreter in my C program and
>have it compile a perl script that spawns one Perl thread, which
>will communicate via the main Perl thread with the C program.
Perl thread support is far from stable.
I would suggest testing the basics with a non-threaded build
if that is possible.
Further comments below.
>
>gcc -o a.out test.o [other .o's]
>-lnsl -lsocket -ldl /usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/B/B.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/ByteLoader/ByteLoader.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Data/Dumper/Dumper.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Devel/DProf/DProf.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Devel/Peek/Peek.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Fcntl/Fcntl.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/File/Glob/Glob.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/IO/IO.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/IPC/SysV/SysV.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/NDBM_File/NDBM_File.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/ODBM_File/ODBM_File.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Opcode/Opcode.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/POSIX/POSIX.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/SDBM_File/SDBM_File.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Socket/Socket.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Sys/Hostname/Hostname.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Sys/Syslog/Syslog.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/Thread/Thread.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/attrs/attrs.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/re/re.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/CORE/libperl.a -lsocket -lnsl -ldl -lm
>-lposix4 -lpthread -lc -lcrypt -lsec
>/adc_local_apps/vcs/vcs6.0/sun_sparc_solaris_5.5.1/lib/libvcs.a
>/usr/local/lib/perl5/5.6.0/sun4-solaris-thread/auto/DynaLoader/DynaLoader.a -lm -lc
>-ldl
Are all the static links really vital? There more possibility of
a name-clash linked that way. It might be worth experimenting with
a sub-set.
>
>This is the stack from gdb:
>
>#0 0x12b45dc in Perl_newSVpvn ()
>#1 0x12d3614 in S_doeval ()
>#2 0x12d5640 in Perl_pp_entereval ()
>#3 0x125210c in S_call_body ()
>#4 0x12522ec in Perl_eval_sv ()
>#5 0x12524f0 in Perl_eval_pv ()
>#6 0x69db7c in getLine (rd=1,
> line=0xffb43a98 "0 print Notice: Will use static file") at test.c:741
>#7 0x6a4840 in scan_up_pipe (save=1, args=0xffbee988, want_out=0xffbee984)
> at test.c:2725
>#8 0x6a4cb4 in arena_start () at test.c:2807
>#9 0x14694c8 in Spli ()
>#10 0x6bb764 in Rganges2_tb_2iJaFb_1_216 ()
>#11 0x133ed8c in CauseAllTS32 ()
>#12 0x133c0a8 in VCS_MAIN ()
>#13 0x6a7c08 in main ()
>
>and here is how I initialize the perl interpreter.
>
>void perlInit() {
> char *args[] = { "perl", "-e", "exit;" };
> printf("C: Initializing Perl interpreter\n");
Er - why do you call exit - I suspect this root cause,
as exit is going to (mostly) destroy the intepreter you
just created. A return, 1, or even "require 'test.pl'" would
be a better choice.
>
> my_perl = perl_alloc();
> perl_construct(my_perl);
>
> perl_parse (my_perl, xs_init, 3, args, (char **)NULL);
> { dTHX; perl_eval_pv ("require 'test.pl';", TRUE); }
>}
FWIW - in threaded land dTHX and my_perl should be same thing (if I recall
correctly) - it is possible that nested dTHX is confusing things.
--
Nick Ing-Simmons
who is looking for a new job see http://www.ni-s.u-net.com/