in reply to Inline::C query

Hello Monks,

I am trying to test the functionality of Inline::c with small examples. For one shown below, I seem to get the result alright when I execute test.pl, still I want to take suggestions from you all. Please guide if I am doing it properly.

One more thing, suppose if I have a .dlls/c-libraries instead of the c-source code, will the approach remain the same? Any alternative ways? Basically, I want to keep perl code and .dlls/c-libraries in separate folders.

Hail Monks!

Raj

test.pl -------------------- use hello qw(addint); my $a=addint(9, 16); print "$a\n"; exit; hello.pm ------------ package hello; use strict; require Exporter; @ISA=qw(Exporter); @EXPORT_OK=qw(addint); use Inline (C => 'cfunction/addint.c'); 1; addint.c ----------------------------- int addint(int x, int y) { return x + y; }

Replies are listed 'Best First'.
Re^2: Inline::C query
by gellyfish (Monsignor) on Mar 02, 2005 at 12:01 UTC

    If you want to link an external library and/or use its include files you need to specify these in the use Inline statement:

    use Inline ( C => Config => LIBS => '-lyourlib', AUTO_INCLUDE => '#include "yourlib.h";' );
    This is discussed in more detail in the Inline::C manpage.

    /J\

      use Inline ( C => Config => LIBS => '-lyourlib', AUTO_INCLUDE => '#include "header.h";' ); function1 (NULL);

      Hi, when I try to run the above program I get the error:

      Undefined subroutine &main::function1 called at ..\..\test.pl line 8 .

      1. From the error it appears that the program is not reading the function "function1" from the header file "header1.h" which it should or from the libraries library1.lib/library1.dll (in the current directory). Kindly suggest what mistake I am making.

      2. In the syntax above, is "-lyourlib" a special switch or does it need to be replaced by the actual library name, ie, "library1.lib". Still, when I replace I get the same error as above.

      3. I also have a .dll file but am not sure if and how I need to use it.

      Thanks very much.