in reply to Re: Using the perl API in C
in thread Using the perl API in C

In fact "-lperl" was my first guess, but that was not found. I didn't realize it was in a non-standard path, so I added "-L/usr/lib64/perl5/5.10.0/x86_64-linux-thread-multi/CORE"; of course it's then not found at runtime, so I added a softlink into /usr/lib64.

But now I'm getting segfaults on basic stuff that worked fine in an XS module. Eg:

SV *r = newSVpv("hello world\0", 16);

Leads to:
Program received signal SIGSEGV, Segmentation fault.
Perl_newSVpv (my_perl=0x0, s=0x400848 "hello world", len=16) at sv.c:6985
6985 new_SV(sv);

Grrrr....

Replies are listed 'Best First'.
Re^3: Using the perl API in C
by Anonyrnous Monk (Hermit) on Dec 20, 2010 at 20:09 UTC

    You'll probably also have to initialise the interpreter (perl_alloc(), perl_construct() - see perlembed for details), so memory management works.

    If you provide a self-contained sample of what you're trying to build, someone here might look into getting it to run... :)

      initialise the interpreter

      Yeah, silly me, I'm sure that would be true.

      a self-contained sample

      Nothing complicated, and I don't really need to do it this way, I can use XS.