Discussion:
How do I debug Inline::C trying to call a library routine?
Chloe
2012-03-14 07:44:47 UTC
Permalink
This is my sample Perl program, and I'm trying to call a library routine. I think it should work, but don't know how to debug what it is doing in the background or where it is failing. It is not providing any error messages that are useful. I don't see any options to turn on verbose or debugging.

--------------------------------------------
use Inline C => Config => ENABLE => "AUTOWRAP" => LIBS => '-L/usr/local/lib -lgretl' => INC => '-I/home/Chloe/gretl-1.9.7/lib/src';

libgretl_init();

__END__
__C__
#include "libgretl.h"
#include "gretl_utils.h"
/*void libgretl_init();*/
----------------------------------------------

This is the error message
-------------------------------------------------
$ perl sample.pl
Undefined subroutine &main::libgretl_init called at sample.pl line 4.
-------------------------------------------------------------------

These are the files generated, but I don't see any .c files. Only the config-*, *.dll, and *.inl have any size.
-----------------------------------------
$ ls -R _Inline/
_Inline/:
build config-i686-cygwin-thread-multi-64int-5.010001 lib
_Inline/build:
_Inline/lib:
auto
_Inline/lib/auto:
e_03e7
_Inline/lib/auto/e_03e7:
e_03e7.bs e_03e7.dll e_03e7.inl
------------------------------------------------------------

This does work, however
------------------------------------------------
$ perl -le 'use Inline C => q{ double erf(double); }, ENABLE => "AUTOWRAP"; print "$_ @{[erf($_)]}" for (0..10)'
0 0
1 0.842700792949715
2 0.995322265018953
...
----------------------------------------------

System version
----------------------------------------
$ uname -a
CYGWIN_NT-5.1 dumbopc 1.7.11(0.260/5/3) 2012-02-24 14:05 i686 Cygwin
-----------------------------------------

The header file:
---------------------------------
$ find gretl-1.9.7 -name \*.h | xargs grep libgretl_init
gretl-1.9.7/lib/src/gretl_utils.h:void libgretl_init (void);
----------------------------------------------
Sisyphus
2012-03-14 09:43:11 UTC
Permalink
----- Original Message -----
From: "Chloe"
Post by Chloe
use Inline C => Config => ENABLE => "AUTOWRAP" => LIBS =>
'-L/usr/local/lib -lgretl' => INC => '-I/home/Chloe/gretl-1.9.7/lib/src';
libgretl_init();
__END__
__C__
#include "libgretl.h"
#include "gretl_utils.h"
These are the files generated, but I don't see any .c files. Only the
config-*, *.dll, and *.inl have any size.
If they were built, and I guess they were, then they've been cleaned up at
the end of the build. (The CLEAN_AFTER_BUILD=>0 config option will prevent
that from happening.)
Post by Chloe
This does work, however
------------------------------------------------
$ perl -le 'use Inline C => q{ double erf(double); }, ENABLE =>
0 0
1 0.842700792949715
2 0.995322265018953
Yes, but this script doesn't:

##################################
use Inline C => Config => ENABLE => "AUTOWRAP";

print "$_ @{[erf($_)]}" for (0..10)

__END__
__C__
double erf(double);

##################################

It outputs: Undefined subroutine &main::erf called at try.pl line 3.
Whereas this script does work:

##################################
use Inline C => Config => ENABLE => "AUTOWRAP";
use Inline C => <<'EOC';
double erf(double);
EOC

print "$_ @{[erf($_)]}" for (0..10)

##################################

See the picture ?
I think something like this might work for you (though I'm not well versed
in AUTOWRAP) :

##################################
use Inline C => Config => ENABLE => "AUTOWRAP" => LIBS =>
'-L/usr/local/lib -lgretl' => INC => '-I/home/Chloe/gretl-1.9.7/lib/src';
use Inline C => <<'EOC';

#include "libgretl.h"
#include "gretl_utils.h"

EOC

libgretl_init();

##################################

Or, perhaps the includes lines need to be rewritten as:
#include <libgretl.h>
#include <gretl_utils.h>

Cheers,
Rob

Loading...