LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-20-2009, 05:56 AM   #1
vinayashrestha
LQ Newbie
 
Registered: Feb 2009
Posts: 9

Rep: Reputation: 0
Need help using LibPerl++ library


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.
 
Old 02-20-2009, 06:01 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
If you don't get a reply soon here, try the Perl gurus at perlmonks.org. Some of the guys who write Perl itself hang out there.
 
Old 02-23-2009, 10:22 PM   #3
vinayashrestha
LQ Newbie
 
Registered: Feb 2009
Posts: 9

Original Poster
Rep: Reputation: 0
Thanks

Thanks for sharing, Chris.
 
Old 02-24-2009, 06:36 AM   #4
vinayashrestha
LQ Newbie
 
Registered: Feb 2009
Posts: 9

Original Poster
Rep: Reputation: 0
A breakthrough

I managed to compile and link my C++ program with the libperl++ library. I declared a variable wPerlScalar which is supported by the library. However, my requirement is that I need to embed Perl Script in C++ application and this library has a class called wPerl which has eval() function that allows to run Perl script. However, the wPerl class constructor has been declared as protected, which means I cannot instantiate the wPerl class. I tried to make the constructor public and built the library again, but it didn't help, Segmentation error. Can any one help me with this ?
 
Old 02-26-2010, 03:58 AM   #5
kumuduharshani
LQ Newbie
 
Registered: Feb 2010
Posts: 1

Rep: Reputation: 0
I have been trying to embed perl with c++ for one of my projects.
There I followed the instructions given in this thread (libperl++)

$perl Makefile.pl - works fine
$make - doesn't work, it gives errors as follows.

make[1]: Entering directory `/home/kumudu/wingPerf/perl/libperl++-1.1/libperl++'
make[2]: Entering directory `/home/kumudu/wingPerf/perl/libperl++-1.1/libperl++/NamedConfig'
Manifying ../../blib/man3/ExtUtils::Libperlxx::NamedConfig.3pm
make[2]: Leaving directory `/home/kumudu/wingPerf/perl/libperl++-1.1/libperl++/NamedConfig'
make[2]: Entering directory `/home/kumudu/wingPerf/perl/libperl++-1.1/libperl++/Default'
Manifying ../../blib/man3/ExtUtils::Libperlxx:efault.3pm
make[2]: Leaving directory `/home/kumudu/wingPerf/perl/libperl++-1.1/libperl++/Default'
make[2]: Entering directory `/home/kumudu/wingPerf/perl/libperl++-1.1/libperl++/static'
g++ -Wall -g -DHAS_BOOL -I../source -I/usr/lib/perl/5.10/CORE -c -o interp.o ../source/interp.cc
In file included from ../source/perl++/interp.hh:5,
from ../source/interp.cc:7:
../source/perl++/scalar.hh:88: error: ‘wPerlArray’ has not been declared
../source/perl++/scalar.hh:89: error: ‘wPerlArray’ has not been declared
../source/perl++/scalar.hh:90: error: ‘wPerlArray’ has not been declared
../source/perl++/scalar.hh:91: error: ‘wPerlArray’ has not been declared
../source/perl++/scalar.hh:107: error: ‘wPerlArray’ has not been declared
../source/interp.cc: In function ‘void libperl_xs_init(PerlInterpreter*)’:
../source/interp.cc:13: warning: deprecated conversion from string constant to ‘char*’
../source/interp.cc: In static member function ‘static wPerl* wPerl::start()’:
../source/interp.cc:216: warning: deprecated conversion from string constant to ‘char*’
../source/interp.cc:216: warning: deprecated conversion from string constant to ‘char*’
make[2]: *** [interp.o] Error 1
make[2]: Leaving directory `/home/kumudu/wingPerf/perl/libperl++-1.1/libperl++/static'
make[1]: *** [subdirs] Error 2
make[1]: Leaving directory `/home/kumudu/wingPerf/perl/libperl++-1.1/libperl++'
make: *** [subdirs] Error 2




can someone help me on this.?
 
Old 03-02-2010, 11:15 AM   #6
chachac
LQ Newbie
 
Registered: Mar 2010
Location: France, Lyon
Distribution: debian
Posts: 1

Rep: Reputation: 0
hello kumuduharshani,
i have exactly the same issue.
did you resolve it?
thank you very much,
charlotte

edit -- ok i have installed libboost-dev and it works =)

Last edited by chachac; 03-05-2010 at 06:01 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
perl library libperl.so error v2010 Mandriva 12 03-10-2006 01:21 PM
libperl.so and apache2 xpucto Solaris / OpenSolaris 20 03-04-2006 02:27 AM
libperl.so big trouble....!!!!!! javier_ccs Linux - Software 1 07-26-2005 10:10 AM
no libperl.so in Slack? BroX Slackware 2 12-01-2004 09:13 AM
what rpm contains libperl.so.5.8 unixmad Linux - Software 2 10-01-2004 04:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration