Getting Up Close and Personal

Chapter 10 - Writing C Modules with Inline::C
by?Sam Tregar?
Apress ? 2002
has companion web siteCompanion Web Site

Inline::C supports a powerful tracing mechanism that can give you information about what it's doing while it's doing it. For example, if I call the preceding script with the command-line parameter –MInline=INFO,FORCE,NOCLEAN, the following output is produced:

 $ perl -MInline=INFO,FORCE,NOCLEAN ./inline.pl <-----------------------Information Section-----------------------------------> Information about the processing of your Inline C code: Your source code needs to be compiled. I'll use this build directory: ./_Inline/build/inline_pl_927a and I'll install the executable as: ./_Inline/lib/auto/inline_pl_927a/inline_pl_927a.so The following Inline C function(s) have been successfully bound to Perl:                void japh() <-----------------------End of Information Section----------------------------> Just Another Perl Hacker. 

The FORCE option tells Inline::C to compile the code even if it hasn't changed. The INFO option produces the output included earlier. As you can see, Inline::C is building in ./_Inline/build/inline_pl_927a. The compiled module (referred to as an executable) is created in this directory. Finally, Inline::C helpfully reports that a single function was successfully bound to Perl: void japh().

By specifying NOCLEAN, Inline::C leaves all its temporary files around for you to inspect. Entering the build directory, I find the following files:

 $ cd _Inline/build/inline_pl_927a $ ls blib              inline_pl_927a.c  Makefile    out.Makefile_PL INLINE.h          inline_pl_927a.o  Makefile.PL out.make_install inline_pl_927a.bs inline_pl_927a.xs out.make    pm_to_blib 

All of these files are useful to understanding how Inline::C works, but the file out.make is of particular importance. It records the output of the compilation phase of your code. If you have a compilation error, Inline::C will output a message like this one:

 A problem was encountered while attempting to compile and install your Inline C code. The command that failed was:   make > out.make 2>&1 The build directory was: /home/sam/book/_Inline/build/inline_pl_8143 To debug the problem, cd to the build directory, and inspect the output files. at ./inline.pl line 2 

By examining the out.make file in the build directory you can determine the exact cause of the compilation error.



Writing Perl Modules for CPAN
Writing Perl Modules for CPAN
ISBN: 159059018X
EAN: 2147483647
Year: 2002
Pages: 110
Authors: Sam Tregar

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net