Sisyphus
Sat, 29 Mar 2008 23:18:30 -0700
----- Original Message ----- From: "second axiom" <[EMAIL PROTECTED]>
To: <inline@perl.org> Sent: Sunday, March 30, 2008 3:56 PM Subject: Inline::C - including an external file and nothing else
Hello.I'm able to create Perl script that uses Inline C and also links to a precompiled C library, but I'm trying to do something else that I think should be equivalent:#!/usr/bin/perl -w use Inline C => <<ENDC; #include <myCcode.c> ENDC test(2);I.e., if I paste the contents of myCcode.c in place of the #include, I get the expected results. I'm trying to get Inline to do that and ignore the fact that the code comes from a separate file, but it refuses to recognize the functions in myCcode.c. (Basically, I prefer to avoid compiling the code myself.)
I created a file called 'src/myCcode.c' which contained:
void greet() {
printf("Hello from myCcode.c\n");
}
I then ran the following Inline::C script:
use warnings;
use Inline C => 'src/myCcode.c';
greet();
which, behaved as desired and printed out (after compiling):
Hello from myCcode.c
However, for some reason, it seems that myCcode.c needs to be in a
subdirectory. If it's placed in the same directory as the Inline::C script,
it doesn't work. This is mentioned in 'perldoc Inline-FAQ'.
Cheers,Rob