Home: Perl Programming Help: Win32 Programming Help:
Call perl script subroutine from C++



sach_1979
Novice

Jun 18, 2009, 11:08 PM


Views: 9032
Call perl script subroutine from C++

Hi all,

I am trying to access perl sub routin from C++ application. I am getting linker error

error LNK2019: unresolved external symbol _Perl_call_pv referenced in function "void __cdecl showtheTime(void)" (?showtheTime@@YAXXZ)

error LNK2019: unresolved external symbol _Perl_markstack_grow referenced in function "void __cdecl showtheTime(void)" (?showtheTime@@YAXXZ)


My perl script is very simple

sub showtime {
print time;
}

and my C++ file I am calling this subroutin using call_pv.

C++ code looks like:

#include
"EXTERN.h"

#include
"perl.h"

static
PerlInterpreter *my_perl;

void
showtheTime()

{

dSP;

PUSHMARK(SP);

call_pv(
" showtime", G_DISCARD | G_NOARGS);

}


void
main()

{

showtheTime();

}

Where am I going wrong here?



Thanks

Sachin



FishMonger
Veteran / Moderator

Jun 19, 2009, 5:02 AM


Views: 9028
Re: [sach_1979] Call perl script subroutine from C++

You should ask C++ questions in one of the C++ forums.


sach_1979
Novice

Jun 19, 2009, 5:31 AM


Views: 9025
Re: [FishMonger] Call perl script subroutine from C++

Hi,

I am extreamly sorry for that.

My question was which all libraries of perl are required for calling Perl subroutine from C/C++?

As I mentioned, I am getting linking errors which means that the perl calls are not finding definitions. So, please let me know hwich all libraries needs to be included.



Thanks

Sachin


FishMonger
Veteran / Moderator

Jun 19, 2009, 5:42 AM


Views: 9022
Re: [sach_1979] Call perl script subroutine from C++

You need to install perl and have your C++ program execute the Perl script and capture its output.