in reply to Re^3: perl c++ perlembed question
in thread perl c++ perlembed question

i dont want to call JUST ANY c function ... i want to call MY OWN functions that got defined/declared in the code that after declaring those functions embedded the perl script. and i want to access those functions from within the embedded perl script

i.e.
blubb.cpp does 2 things ... declaring foobar() and embedding lalala.pl

now i want to call foobar() from within the embedded lalala.pl

i really dont know how else i should explain it ... it seems nobody understands me :-(

Replies are listed 'Best First'.
Re^5: perl c++ perlembed question
by Anonymous Monk on Jun 28, 2009 at 05:10 UTC
    Hmm, didn't I just describe that exact scenario?
      didn't I just describe that exact scenario?

      I think you've dealt with a slightly different scenario.
      Both Win32::API and C::DynaLib can load functions from dynamic libraries but, as I (currently) understand it, the op is wanting to load functions from an executable. I don't think those modules can help with that.

      Cheers,
      Rob

        As far as Win32 is concerned, there is very little difference between a .exe and a .dll. If a function in a .exe is exported--they usually aren't but there is not reason why they cannot be--then Win32::API will be able to load and call that function. You just name the .exe inplace of the .dll in the call:

        use Win32::API; my $function = Win32::API->new( 'theExe.exe, 'int foo( int a, int b )', ); $return = $function->Call(3, 2);

        If the .exe in question happened to be the same .exe that is currently running an embedded Perl interpreter, that would work fine too.

        Whether this symmetry holds true for other OSs I have no idea.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.