Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling c executables from a Perl Module::Build module

Tags:

perl

In this question about compiling c code in a Module::Build module, it was suggested to use c_source to specify the location of the c/c++ source code.

This configuration option results in compiling the source to object files, and adding the directory to the linker's search path.

I would like to know if a similar configuration can be achieved, where all .c files are compiled to standalone executables, and installed next to the bin/ scripts.

like image 442
ajwood Avatar asked Jul 29 '14 14:07

ajwood


People also ask

Does Perl compile to C?

Since version 5.005, Perl has shipped with a module capable of inspecting the optimized parse tree ( B ), and this has been used to write many useful utilities, including a module that lets you turn your Perl into C source code that can be compiled into an native executable.

Does Perl have a compiler?

The compiler allows you to distribute Perl programs in binary form, which enables easy packaging of Perl-based programs without having to depend on the source machine having the correct version of Perl and the correct modules installed.

Can Perl scripts be compiled?

Interpreted Languages like Perl require the interpreter and other modules on the system to run the program. Thankfully, there are options available for compiling perl scripts into binaries. PAR is an excellent cross-platform package that can accomplish this goal.


1 Answers

You could check out the Alien:: set of modules, which do a superset of what you want I think. It looks like https://metacpan.org/pod/Alien::Base::Authoring is a good place to start.

like image 191
awwaiid Avatar answered Oct 06 '22 01:10

awwaiid