Reputation: 21
I am fairly new to Perl and C++. I have a simple C++ code. I have to call its member functions and update its member variables from Perl.
I looked at several options but found them too confusing. Is there a way this can be done easily? Thank you.
Upvotes: 0
Views: 91
Reputation: 126732
There is nothing that is simple and straightforward I'm afraid. From the nature of your application, it sounds like you are just experimenting with things, and it is probably not worth the work unless you are preparing for a more complex interface.
The standard way of calling C code from within Perl is to write XS code. It's documented in perldoc perlxs
. There is a specific section on Using XS With C++ and a tutorial in perldoc perlxstut
. But it sounds like you have already come across that and found it too confusing
If your code was built as a DLL then you could use Win32::API
to call the exported functions
Beyond that there isn't much I can suggest. If you explain your application, and why you are writing arithmetic functions in C++ then I'm sure we could suggest a better alternative
Upvotes: 1