Generate executable from perl scripts that uses Inline::C?

C

cmaster

Dear all,

I would like to ask would it be possible to generate executable from
perl scripts that uses Inline::C?

I used to be able to generate executables from 'normal' perl scripts
(those without any Inline C codes) by using the command "perlcc -o
hello hello.pl". (I'm using Perl v5.8.0, Inline 0.44 under linux )

However I have no idea on how it could be done to perl scripts that
have Inline C codes. (Could this be done actually?)

I've tried the following commands (attempting to generate an
executable and
then run it) for the perl script below (with is taken from one of the
examples in the Inline C Recipes):
perl myperl.pl
perlcc -o myperl myperl.pl
./myperl

It just failed and gives the following error message:

--------------------------------------------------------------------------------
No source code in DATA section for Inline 'C' section.

at /opt/Perl/lib/perl5/5.8.0/i686-linux/Socket.pm line 0
INIT failed--call queue aborted.
--------------------------------------------------------------------------------

I've tried some subject searches in this group though, but I found
nothing.
I've also been reading all around for some kind of instructions on how
this
could probably been done in the Inline C's Cookbook, FAQs and pods
etc, but I
seem unable to find anything related. (I remember I saw something
about
creating a binary distribution for Perl modules, but not Perl
scripts).

I know that this question may sound trivial, but I've been struggling
with it for a few days but still without any success.

Any help or pointers to the problem will be much appreciated. Thanks.

Regards,
cmaster

==================================================================
## this is the source code for myperl.pl ##

use Inline C;

c_func_1('This is the first line');
c_func_2('This is the second line');

sub perl_sub_1 {
print map "$_\n", @_;
}

__DATA__
__C__

void c_func_1(SV* text) {
c_func_2(text);
}

void c_func_2(SV* text) {
Inline_Stack_Vars;
Inline_Stack_Push(newSVpvf("Plus an extra line"));
Inline_Stack_Done;
perl_call_pv("main::perl_sub_1", 0);
Inline_Stack_Void;
}

=======================================================================
 
B

Ben Morrow

I used to be able to generate executables from 'normal' perl scripts
(those without any Inline C codes) by using the command "perlcc -o
hello hello.pl". (I'm using Perl v5.8.0, Inline 0.44 under linux )

However I have no idea on how it could be done to perl scripts that
have Inline C codes. (Could this be done actually?)

perlcc has always been experimental and not recommended for production
use. You'll probably be better off with PAR. If this won't handle
Inline::C scripts, then you could always factor the Inline stuff out
into a module (probably a good idea anyway), install that module and
then PAR it up.

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top