enemyofthestate has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to use Inline::C in a perl module. The C code appears to compile fine (at least there is a .so file in the right place) but the module does not return a true value to the calling program and I cannot figure out how to make that work. I've tried putting the usual "1;" at various places in the code but it either chokes when compiling or tells me:
"DLDtest.pm did not return a true value at bin/dldtest.fcgi line 11."
Anyone know how to make this work?
This is some stripped down code I am using to test with:dldtest.fcgi
#!/usr/bin/perl use strict; use warnings; use File::Basename; use FindBin; use lib dirname($FindBin::Bin) . "/modules"; use DLDtest; my ($dlid,@dlfiles) = dld_initialize("lic_file", "123456", 5, "/path/t +o/data/files"); exit 0;
DLDtest.pm
package DLDtest; use strict; use warnings; use Exporter qw(import); use English; our @EXPORT = qw (dld_initialize); #------------------------------------------------ # initialize dld and open data files #------------------------------------------------ sub dld_initialize { my ($lic_file, $password, $num_files, $dl_format) = @_; my @files = (); # initalize the DLD library my $dlid = dl_DlInit(""); # set the license file and password unless (dl_DlSetLicense($dlid, $lic_file, $password)) { return (0,@files); } # open the DLD files for (my $cntr = 0; $cntr < $num_files; $cntr++) { my $path = sprintf($dl_format, $cntr + 1); my $fileid = dl_DlFileOpen($dlid, $path); $files[$cntr] = $fileid ? $fileid : 0; } return ($dlid,@files); } #------------------------------------------------ # C functions to interface with Pitney library #------------------------------------------------ use Inline (C => Config => DIRECTORY => '/var/www/addrez/Inline', INC => "-I/var/www/addrez/ext.att/include", LIBS => '-L/var/www/addrez/ext.att/lib -ldemolibMT'); use Inline "C"; Inline->init; __DATA__ __C__ #include "dl.h" /*----------------------------------------------- * Initialize the DLD librariy *---------------------------------------------*/ long dl_DlInit (SV* initPath) { return DlInit(SvPV (initPath, PL_na)); } /*----------------------------------------------- * associate a license file and password with dl *---------------------------------------------*/ int dl_DlSetLicense(long dl, char* licenseFile, long password) { return DlSetLicense(dl, licenseFile, password); } /*----------------------------------------------- * open a data file and return FileID *---------------------------------------------*/ long dl_DlFileOpen (long dl, char *path) { return DlFileOpen(dl, path); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Inline::C in a Perl module
by huck (Prior) on Sep 18, 2017 at 19:14 UTC | |
by pryrt (Abbot) on Sep 18, 2017 at 19:29 UTC | |
by enemyofthestate (Monk) on Sep 18, 2017 at 20:54 UTC | |
by huck (Prior) on Sep 18, 2017 at 19:49 UTC | |
|
Re: Inline::C in a Perl module
by syphilis (Archbishop) on Sep 18, 2017 at 23:16 UTC |