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


In reply to how use the Inline::CPP module with a custom library by earlati2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.