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.