Edmund
Edmund

Reputation: 737

How do I create a static library with C or C++ linkage from a Perl module?

I have a very big Perl module, and I am expecting to call it in my Visual C++ project. I know there are tools like perl2exe and pp that can convert Perl modules to standalone executables (abc.exe).

I don't like the standalone executable because it makes the interface very complex. I have to call the Perl module by creating a process and communicating with it using standard input/output.

It will be much easier if the Perl module is a C/C++ static library. Just link it and call a function!

Thanks in advance!

Upvotes: 1

Views: 542

Answers (2)

ikegami
ikegami

Reputation: 385496

You can indeed statically link your module into your C project. The thing to realise is that you need to link in perl too. perl is a library heavily used by Perl code (and it would be so even if Perl code could be compiled to machine language).

perlembed documents how to do this.

Upvotes: 1

daxim
daxim

Reputation: 39158

You can't (yet|easily) compile modules. Instead, embed the Perl interpreter as a library.

Upvotes: 2

Related Questions