I attempted to use the libperl++ library to embed Perl in C++. The procedure I followed and the problems I faced are listed below:
1. Installation
I downloaded the library from following location
http://www.vulpes.com/libperl++-1.1.tar.gz
Then unzipped it as
tar -xzvf libperl++-1.1.tar.gz
This produces a folder libperl++1.1.
Then, as instructed in the README file, i installed the library as
$perl Makefile.pl
$make
$make test
$make install
The library is now installed in the following location:
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/ExtUtils/libperl++/gnu
Following files are installed:
1. libperl++ header and class files
2. libperl++.so.1.1
3. libperl++.a
4. libperl++.so
2. Library Test
Then i wrote a simple program as instructed in a tutorial here:
http://www.perl.org/tpc/1998/User_Ap...ugh/paper.html
#include <perl++.hh>
wPerlScalar r = 0;
for (int i = 0; i < 100; ++i)
{
r = r + i;
}
I tried to compile this program as:
$ g++ test.cpp -o test
-I /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/ExtUtils/libperl++/gnu
-L /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/ExtUtils/libperl++/gnu
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/ExtUtils/libperl++/gnu/libperl++.a
-lperl -lm
I tried to compile both including and excluding the libperl++.a library. But all these times, i got the following error message
/tmp/cc85zT3J.o(.text+0x27): In function `main':
: undefined reference to `wPerlScalar::wPerlScalar(int)'
/tmp/cc85zT3J.o(.text+0x46): In function `main':
: undefined reference to `wPerlScalar:perator+=(int)'
/tmp/cc85zT3J.o(.text+0x62): In function `main':
: undefined reference to `wPerlScalar::~wPerlScalar()'
/tmp/cc85zT3J.o(.text+0x7f): In function `main':
: undefined reference to `wPerlScalar::~wPerlScalar()'
collect2: ld returned 1 exit status
This is all I have done so far and here I am stuck with this error. I would appreciate it very much if someone helped me get out of this. Thanks.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.