in reply to creating module for Inline C

It's ok to create a module that uses Inline::C for part of its implementation. To the outside world it looks like any other module.

I've done it like this for example:

package ABC::DEF::G; ... # Preloaded methods go here. use Inline CPP => Config => INC => '-I/usr/X11R6/include/', LIBS => '-L/usr/X11R6/lib -lX11', CLEAN_AFTER_BUILD => 0; use Inline CPP => <<'END';
What you may not know is that the extension will be rebuilt for every perl program that uses the module, in the directory where the program is run. If you want real compiled-once-and-installed extensions you have to bite the bullet and use XS.

Update: Recompilation will happen for the Inline::CPP example I show here, but it is possible to make the extension behave more like a true module by proper use of VERSION, NAME, and Inline::MakeMaker, as documented in Writing Modules with Inline.

As for exporting a symbol from the extension as you try to do, I doubt that will work. Why not wrap the call in a perl routine and just export that?

Thanks to Fletch and dbp for corrections.

Replies are listed 'Best First'.
Re: Re: creating module for Inline C
by Fletch (Bishop) on Jan 29, 2003 at 18:33 UTC
    If you want real compiled-once-and-installed extensions you have to bite the bullet and use XS.

    Actually this is incorrect. See the section entitled Writing Modules with Inline in the Inline perldoc.

Re: Re: creating module for Inline C
by dbp (Pilgrim) on Jan 29, 2003 at 21:04 UTC

    As for exporting a symbol from the extension as you try to do, I doubt that will work.

    Actually, that will work just fine, check out the source of Audio::Ao for an example.

    To the original poster: Move the config directives out of the __DATA__ section and into the perl portion like so:

    use Inline C => 'DATA', INC => '...', LIBS => '...', VERSION => '0.02', NAME => 'MYMODU::mystuff';