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?
Inline::C generates a
.xsfile 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 anyfoo.corbar.cfor the tool chain to compile.What you could do is create a library (static or shared) from the two compilation units you describe (
foo.candbar.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.