----- Original Message ----- From: "Sean McMahon" <[EMAIL PROTECTED]>
To: <Inline@perl.org>
Sent: Wednesday, May 09, 2007 6:31 AM
Subject: problem compiling perl with inline c program uses a shared lib.


I have attached my script connect and the error log. Please help I'm trying to
go from the example provided by the c-cookbook for inline.
(see attached files connect and connectbuggs.log)
Sean

Rewriting the script as follows should at least enable the Inline::C code to compile:
----------------------------------
#!/usr/opt/bin/perl
use Inline C => Config =>
LIBS => '-L/usr/opt/nwis/lib -lnw';
use Inline C => <<'END_OF_C_CODE';
#include "nw.h"
END_OF_C_CODE

nw_sql_connect (nw_db_nm (), "ownereditor");
----------------------------------
(The closing "END_OF_C_CODE" needs to go hard up against the left hand margin, and you forgot the "=>" in the 4th line in the above code.)

It won't compile for me - but only because I don't have nw.h.

Once it does compile, the perl code will die because perl has no way of knowing what nw_sql_connect() and nw_db_nm() are.

I'm guessing that these are functions defined in the nw library - in which case you probably want to wrap nw_sql_connect() so that the script will look something like this:
-----------------------------------
#!/usr/opt/bin/perl
use Inline C => Config =>
LIBS => '-L/usr/opt/nwis/lib -lnw';
use Inline C => <<'END_OF_C_CODE';
#include "nw.h"

void wrap_nw_sql_connect( char * y) {
    nw_sql_connect(nw_db_nm(), y);
}

END_OF_C_CODE

wrap_nw_sql_connect ("ownereditor");
-----------------------------------

Bear in mind that I'm only guessing - the above code may not function correctly (if at all :-)

I take it that you're not interested in catching the return value of nw_sql_connect() - if, indeed, it does return anything at all.

Cheers,
Rob

Reply via email to