1Inline-FAQ(3) User Contributed Perl Documentation Inline-FAQ(3)
2
3
4
6 Inline-FAQ - The Inline FAQ
7
9 Welcome to the official Inline FAQ. In this case, FAQ means:
10
11 Formerly Answered Questions
12
13 This is a collection of old, long-winded emails that myself and others
14 have sent to the Inline mailing list. (inline@perl.org) They have been
15 reviewed and edited for general Inline edification. Some of them may be
16 related to a specific language. They are presented here in a
17 traditional FAQ layout.
18
20 Since there is only a handful of content so far, all FAQs are currently
21 under this heading.
22
23 How disposable is a .Inline or _Inline directory?
24 I probably need to be more emphatic about the roll of _Inline/ cache
25 directories. Since they are created automatically, they are completely
26 disposable. I delete them all the time. And it is fine to have a
27 different one for each project. In fact as long as you don't have
28 ~/.Inline/ defined, Inline will create a new ./_Inline directory
29 (unless, you've done something to override this automatic process -
30 such as using the DIRECTORY config option, or using the
31 PERL_INLINE_DIRECTORY environment variable). You can move that to
32 ./.Inline and it will continue to work if you want togive it more
33 longevity and hide it from view. There is a long complicated list of
34 rules about how [_.]Inline/ directories are used/created. But it was
35 designed to give you the most flexibility/ease-of-use. Never be afraid
36 to nuke 'em. They'll just pop right back next time they're needed. :)
37
38 Whatever happened to the SITE_INSTALL option?
39 SITE_INSTALL is gone. I was going to leave it in and change the
40 semantics, but thought it better to remove it, so people wouldn't try
41 to use it the old way. There is now _INSTALL_ (but you're not supposed
42 to know that :). It works magically through the use of
43 Inline::MakeMaker. I explained this earlier but it's worth going
44 through again because it's the biggest change for 0.40. Here's how to
45 'permanently' install an Inline extension (Inline based module) with
46 0.40:
47
48 1) Create a module with Inline.
49 2) Test it using the normal/local _Inline/ cache.
50 3) Create a Makefile.PL (like the one produced by h2xs)
51 4) Change 'use ExtUtils::MakeMaker' to 'use Inline::MakeMaker'
52 5) In the Makefile.PL's WriteMakefile() insert:
53
54 CONFIGURE_REQUIRES => {
55 'Inline::MakeMaker' => 0.45,
56 'ExtUtils::MakeMaker' => 6.52,
57 },
58
59 (See the "Writing Modules with Inline" section of Inline.pod for
60 an explanation/elaboration.)
61
62 6) Change your 'use Inline C => DATA' to 'use Inline C => DATA => NAME
63 => Foo => VERSION => 1.23'
64 7) Make sure NAME matches your package name ('Foo'), or begins with
65 'Foo::'.
66 8) If you want to quiet a harmless warning that will appear when the
67 module is loaded via "require", do "Inline->init();".
68 See "Writing Modules with Inline" in the Inline pod for details.
69 9) Make sure VERSION matches $Foo::VERSION. This must be a string (not a
70 number) matching /^\d\.\d\d$/
71 10) Do the perl/make/test/install dance (thanks binkley :)
72
73 With Inline 0.41 (or thereabouts) you can skip steps 3 & 4, and just
74 say 'perl -MInline=INSTALL ./Foo.pm'. This will work for non-Inline
75 modules too. It will become the defacto standard (since there is no
76 easy standard) way of installing a Perl module. It will allow
77 Makefile.PL parameters 'perl -MInline=INSTALL ./Foo.pm -
78 PREFIX=/home/ingy/perl' and things like that. It will also make use of
79 a MANIFEST if you provide one.
80
81 How do I create a binary distribution using Inline?
82 I've figured out how to create and install a PPM binary distribution;
83 with or without distributing the C code! And I've decided to share it
84 with all of you :)
85
86 NOTE: Future versions of Inline will make this process a one line
87 command. But for now just use this simple recipe.
88
89 ---
90
91 The Inline 0.40 distribution comes with a sample extension module
92 called Math::Simple. Theoretically you could distribute this module on
93 CPAN. It has all the necessary support for installation. You can find
94 it in Inline-0.40/modules/Math/Simple/. Here are the steps for
95 converting this into a binary distribution *without* C source code.
96
97 NOTE: The recipient of this binary distribution will need to have the
98 PPM.pm module installed. This module requires a lot of other CPAN
99 modules. ActivePerl (available for Win32, Linux, and Solaris) has all
100 of these bundled. While ActivePerl isn't required, it makes things (a
101 lot) easier.
102
103 1) cd Inline-0.40/Math/Simple/
104
105 2) Divide Simple.pm into two files:
106
107 ---8<--- (Simple.pm)
108 package Math::Simple;
109 use strict;
110 require Exporter;
111 @Math::Simple::ISA = qw(Exporter);
112 @Math::Simple::EXPORT = qw(add subtract);
113 $Math::Simple::VERSION = '1.23';
114
115 use Inline (C => 'src/Simple.c' =>
116 NAME => 'Math::Simple',
117 VERSION => '1.23',
118 );
119 1;
120 ---8<---
121 ---8<--- (src/Simple.c)
122 int add (int x, int y) {
123 return x + y;
124 }
125
126 int subtract (int x, int y) {
127 return x - y;
128 }
129 ---8<---
130
131 So now you have the Perl in one file and the C in the other. The C code
132 must be in a subdirectory.
133
134 3) Note that I also changed the term 'DATA' to the name of the C file.
135 This will work just as if the C were still inline.
136
137 4) Run 'perl Makefile.PL'
138
139 5) Run 'make test'
140
141 6) Get the MD5 key from 'blib/arch/auto/Math/Simple/Simple.inl'
142
143 7) Edit 'blib/lib/Math/Simple.pm'. Change 'src/Simple.c' to
144 '02c61710cab5b659efc343a9a830aa73' (the MD5 key)
145
146 8) Run 'make ppd'
147
148 9) Edit 'Math-Simple.ppd'. Fill in AUTHOR and ABSTRACT if you wish.
149 Then change:
150
151 <CODEBASE HREF="" />
152
153 to
154
155 <CODEBASE HREF="Math-Simple.tar.gz" />
156
157 10) Run:
158
159 tar cvf Math-Simple.tar blib
160 gzip --best Math-Simple.tar
161
162 11) Run:
163
164 tar cvf Math-Simple-1.23.tar Math-Simple.ppd Math-Simple.tar.gz
165 gzip --best Math-Simple-1.23.tar
166
167 12) Distribute Math-Simple-1.23.tar.gz with the following instructions:
168
169 A) Run:
170
171 gzip -d Math-Simple-1.23.tar.gz
172 tar xvzf Math-Simple-1.23.tar
173
174 B) Run 'ppm install Math-Simple.ppd'
175
176 C) Delete Math-Simple.tar and Math-Simple.ppd.
177
178 D) Test with:
179
180 perl -MMath::Simple -le 'print add(37, 42)'
181
182 ---
183
184 That's it. The process should also work with zip instead of tar, but I
185 haven't tried it.
186
187 The recipient of the binary must have Perl built with a matching
188 architecture. Luckily, ppm will catch this.
189
190 For a binary dist *with* C source code, simply omit steps 2, 3, 6, and
191 7.
192
193 If this seems too hard, then in a future version you should be able to
194 just type:
195
196 make ppm
197
198 Why does C/t/09parser.t fail on Cygwin ?
199 It doesn't always fail on Cygwin, but if you find that it produces
200 "unable to remap .... to same address as parent" errors during the
201 build phase, then it's time for you to run rebaseall.
202
203 See
204 http://cygwin.com/faq/faq-nochunks.html#faq.using.fixing-fork-failures
205 and, if needed, seek further help from the Cygwin mailing list.
206
207
208
209perl v5.16.3 2012-11-20 Inline-FAQ(3)