It should be:
use Inline C => Config => LIBS => '-lparser';
but that pre-supposes that there actually is a library named libparser.a that is going to resolve the symbol. If that's not the case then different action needs to be taken. Fawk, the library is actually named 'libfoo.a', in which case you need to:
use Inline C => Config => LIBS => '-lfoo';
and if the library is not to be found in one of the locations that is searched by default:
use Inline C => Config => LIBS => '-L/path/to/lib -lfoo';
It's also a good idea to force a verbose (noisy) build, as the compiler warnings you then see may help solve the problem:
use Inline C => Config => BUILD_NOISY => 1, LIBS => '-L/path/to/lib -lfoo';
If, however, there's no library at all that resolves parser(), then you need to spell the function out in the C code in the script:
use Inline C => <<END_C; #include <stdio.h> #include <stdlib.h> #include <string.h> // Wild guess follows: int parser (char * url, char * page, char * pool, int lenx2) { // C code that does whatever // it is that parser()does. } char* MyParser(char *url, char* page) { char *pool; int len; int ret; len = strlen(page); // page = (char*)malloc(len); pool = (char*)malloc(2*len+1); // parsing page ret = parser(url, page, pool, 2*len+1); if(ret > 0) return pool; free(pool); } END_C
Seems to me that once you get the C code to compile, the perl code will croak because you're calling MyParser() with one arg, but it needs 2 args.

Cheers,
Rob

In reply to Re^3: Help with Inline C by syphilis
in thread Help with Inline C by downer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.