I compile XS code to object code and link it in with my executable that has an embedded perl. The XS code call functions declared in the main executable; it's a callback module. The perl can't see my linked in module. When I "use Callback;" it dies looking for Callback.pm on the disk. If I make a Callback.pm and have it xsloader-bootstrap 'Callback' it dies looking for the .so. I have the proper boot functions in xs_init.

I'm quite lost. I got valid Callback.xs code that compiles fine to object code. I got "EXTERN_C void boot_Callback (pTHX_ CV* cv);" setup in the xs_init function, along with DynaLoader (which works fine). I got the perl in my main executable working fine and linking with my XS object code fine. But my Callback module DOESN'T WORK! Perl just keeps looking for stuff on the disk. How do I tell perl it doesn't need to do that?

This is all C++ using g++, if it matters.

Makefile: ... main : Callback.o ... $(CC) -o $@ $^ $(PERLLD) Callback.o : Callback.xs xsubpp Callback.xs > Callback.c $(CC) -c Callback.c $(PERLCXX)

Update: Got it working. All I had to do was add to the C++ code eval_pv("Callback::boot_Callback();", true);


In reply to embedded perl using linked in XS modules by kingkongrevenge

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.