After my initial gaff, I'll have another crack at providing something that might be marginally useful - and I second stevieb's request for more info.
Inline::CPP and (Inline::C) seem to be quite happy to directly access the library's version() function: Here's the Inline::CPP demo:
################ package FOO; use strict; use warnings; use Inline CPP => Config => BUILD_NOISY => 1, ; use Inline CPP => <<'EOC'; int version(void * p) { return 42; } EOC my $sv = 'whatever'; my $obj = bless \$sv, 'FOO'; print $obj->version(); ################
That works just fine and outputs '42'.
Of course, it's a little bit different in your case because version() is in a separate library, so your script would be something like:
################ package FOO; use strict; use warnings; use Inline CPP => Config => INC => '/path/to/include', LIBS => '-L/path/to/library -lmy_lib', BUILD_NOISY => 1, ; use Inline CPP => <<'EOC'; #include <my_lib.h> int wrap_version(SV * p) { return version(p); } EOC my $sv = 'whatever'; my $obj = bless \$sv, 'FOO'; print $obj->wrap_version(); ################
or, if you want to call the sub from perl as "version":
################ package FOO; use strict; use warnings; use Inline CPP => Config => PREFIX => 'wrap_', INC => '/path/to/include', LIBS => '-L/path/to/library -lmy_lib', BUILD_NOISY => 1, ; use Inline CPP => <<'EOC'; #include <my_lib.h> int wrap_version(SV * p) { return version(p); } EOC my $sv = 'whatever'; my $obj = bless \$sv, 'FOO'; print $obj->version(); ################
I think SWIG should be capable of providing the same result.

Cheers,
Rob

In reply to Re: interface perl to C++ code with SWIG, re: void pointers? by syphilis
in thread interface perl to C++ code with SWIG, re: void pointers? by velVerlet1

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.