I'm trying to use the Inline::CPP module with a custom library.
The library is something as follow:
class ae_util {
public:
ae_util();
~ae_util();
static string str_time( char * str_fmt = "%Y%2m%2d_%2H%2M%2S" );
.........
body ae_util.cpp
// ****************************
ae_util::ae_util()
{
}
// ****************************
ae_util::~ae_util()
{
}
/************************************************************
************************************************************/
string ae_util::str_time( char * str_fmt )
{
string sres;
char str_res[100];
const time_t now = time(0);
strftime( str_res, 100, str_fmt, localtime( &now ) );
sres = string(str_res);
return sres;
}
I compiled the files inside a kdevelop project and the convert it as library from the obj file as:
$ gcc --shared -o ae_util.so ../xxx/yyyy/ae_util.o
At last I tried to use it inside a perl program as follow
#!/usr/bin/perl use Inline CPP => Config => LIBS => './ae_util.so'; use strict; print " test1 ", ae_util::strtime( '%Y%2m%2d_%2H%2M%2S' );
I get the following error:
Undefined subroutine &ae_util::strtime called at ./inline2.pl line 11.
or
#!/usr/bin/perl
# use Inline CPP => Config => MYEXTLIBS => './ae_util.so'; use Inline CPP => Config => LIBS => './ae_util.so'; use strict; my $obj = new ae_util(1); print " test1 ", $obj->strtime( '%Y%2m%2d_%2H%2M%2S' );
I get the following error:
Can't locate object method "new" via package "ae_util" (perhaps you forgot to load "ae_util"?) at ./inline2.pl line 7.
Where I'm wrong on that ?
there are somewhere some good tutorial about using external custom library with perl program ?
regards, Enzo
20060803 Janitored by [id://5348]: Removed FONT tags, added formatting, code tags, as per [id://17558]
Is only a test
What I need is a way to conenct direcly with shared-memopry and ipc message queue managed in C.
C appli some optmisation so it's very difficult map correclty with the shared-memory fields using the perl statement for shared memory
I hope to reuse the original C code inside perl to avoid future problem when code will be modified, but it doesn't seems to works.
So I will try rewrite the piece of C code I need inside the Inline section.
That rings a bell. Maybe this will be helpful shared mem segments with Inline::C. Of course I'm not expert on this.
perlmonks.org content © perlmonks.org and earlati2, holli, syphilis, zentara
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03