earlati2 has asked for the wisdom of the Perl Monks concerning the following question:
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<br> # 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 fo +rgot 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 Corion: Removed FONT tags, added formatting, code tags, as per Writeup Formatting Tips
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how use the Inline::CPP module with a custom library
by syphilis (Archbishop) on Aug 03, 2006 at 11:34 UTC | |
|
Re: how use the Inline::CPP module with a custom library
by holli (Abbot) on Aug 03, 2006 at 11:20 UTC | |
by earlati2 (Beadle) on Aug 03, 2006 at 13:28 UTC | |
|
Re: how use the Inline::CPP module with a custom library
by zentara (Cardinal) on Aug 03, 2006 at 15:50 UTC |