Does perl Inline::C support multiple dependent C files?

103 Views Asked by At

This question is based on: Perl: how can I put all my inline C code into a separate file?, but for multiple files.

Suppose you want to include C file in perl named foo.c:

#include "bar.h"

int foo(...

As you can see, foo.c depends on bar.h which is associated to bar.c.

Is there a way Inline::C can compile both foo.c and bar.c and link bar.o so foo() works properly?

1

There are 1 best solutions below

0
On

Inline::C generates a .xs file in a previously non-existent directory from the provided code. It then uses the standard Perl tool chain to create a shared library from it. At no point is there any foo.c or bar.c for the tool chain to compile.

What you could do is create a library (static or shared) from the two compilation units you describe (foo.c and bar.c). Inline::C can easily link to these. Alien provides infrastructure for creating libraries for modules to use. This page documents how to create an Alien::* module which builds your library.