Has the same capability not been ported to Inline::C ?

I've had a look ... and the capability in question has NOT been ported to Inline::C, but it seems do-able.
Firstly, the patch to Inline/C.pm:
--- C.pm_orig 2021-12-20 22:11:48 +1100 +++ C.pm 2022-06-27 19:27:27 +1000 @@ -177,6 +177,10 @@ $o->{ILSM}{XS}{PREFIX} = $value; next; } + if($key eq 'OBJECT') { + $o->add_string($o->{ILSM}{MAKEFILE}, $key, $value); + next; + } if ($key eq 'FILTERS') { next if $value eq '1' or $value eq '0'; # ignore ENABLE, +DISABLE $value = [$value] unless ref($value) eq 'ARRAY';
And the Inline::C demo:
use warnings; use Inline C => Config => BUILD_NOISY => 1, OBJECT => '$(O_FILES)', ; use Inline C =><<'EOC'; #include "bar.h" #include "baz.h" void foo(int i) { printf("bar: %d\n", bar(i)); printf("baz: %d\n", baz(i)); } EOC foo(42);
bar.h prototypes the bar function:  int bar (int);
baz.h prototpyes the baz function:  int baz (int);
bar.c defines the bar() function:
#include "bar.h" int bar (int in) { return in; }
and baz.c defines the baz() function:
#include "baz.h" int baz (int in) { return in + 1; }
It's probably important that each of those 4 files terminate with at least one empty line.

But there's a snag I haven't quite got around yet: The first time I run my Inline::C script, it fails to compile because of undefined references to 'bar' and 'baz'. I then manually copy bar.h, baz.h, bar.c and baz.c to the Inline build directory that was created by that first run ... then I re-run the script, and all goes fine. And I end up with the expected output of:
bar: 42 baz: 43
So ... I wonder if there's some way that I can make bar.h, baz.h, bar.c and baz.c visible to the build process without having to move them to the build directory ?
Essentially, I think the problem is that, with the current OBJECT => '$(O_FILES)' arg, the .c snd .h files need to be in the same directory as the auto-generated Makefile.PL (ie the script's build directory).
I'm hoping there's some way to get the message across that we want to use the .c and.h files from a different location.
Otherwise, we face the task of getting Inline to move those files across to the build directory *before* the auto-generated Makefile.PL is run.

Any ideas ? (I'll keep fiddling with it and see if I can come up with the right solution.)
Having to manually copy files and re-run commands strikes me as being a little less than optimal ;-)

Cheers,
Rob

In reply to Re^3: Better way to force Inline to use compiled binary instead of C source? by syphilis
in thread Better way to force Inline to use compiled binary instead of C source? by vr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.