Home: Perl Programming Help: Beginner:
Need help to call perl module from C/C++ code without loading the perl libraries



muraliv
New User

Oct 2, 2012, 3:53 AM


Views: 2451
Need help to call perl module from C/C++ code without loading the perl libraries

Hi,

I am new to perl. I have a requirement to call a perl module from C/C++ code without loading the perl libraries. I am not supposed to use the "system" call also. I am looking something similar to "dlopen" call which we use to load the shared libraries dynamically from a C/C++ code. Basically I wanted to keep perl and C/C++ code independently. Generally we can embed the perl into C/C++ code by including the include files EXTERN.h and perl.h. While compiling the C/C++ code, we need to provide the perl libraries. As per my requirement, I am not supposed to provide any perl libraries while compiling the C/C++ code.

Any idea how to call perl module from C/C++ code without loading the perl libraries other than “system” call?

Thanks in advance.

Regards,
Murali


rovf
Veteran

Oct 17, 2012, 7:21 AM


Views: 1987
Re: [muraliv] Need help to call perl module from C/C++ code without loading the perl libraries

If I understand you correctly, you want to have the Perl stuff run in a separate process from your C++ program. You did not provide any hint about what kind of data need to be sent between the two processes.

You can start your Perl process in parallel to your main program (i.e. independently), and then use a socket connection to have them talk to each other. Of course the tricky part is to pass the data around - you will have to do some type of marshalling -, but if the interface between the two is lean enough, this should be not too difficult.

Have a look at IO::Socket for the Perl side of the socket communication.