dusty678 has asked for the wisdom of the Perl Monks concerning the following question:

hey guys,

this is my first posting, i've been googling for answers but so far no joy..

i'm trying to embed perl statements in C++ (g++ on linux
actually), and i've followed the perlembed doc,
which works great for C but when i try to include iostream
libraries (or any STL libraries) seems to have a problem.

here's what i've got:
// to compile do
// % g++ -o myperl myperl2.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
#include <EXTERN.h> /* from the Perl distribution */

#include <perl.h> /* from the Perl distribution */

//#include <iostream> // this line is causing problems, probably the STL library conflict with perl

using namespace std;

static PerlInterpreter *my_perl; /*** The Perl interpreter ***/

int main(int argc, char **argv, char **env)
{

my_perl = perl_alloc();
perl_construct(my_perl);
perl_parse(my_perl, NULL, argc, argv, (char **)NULL);

perl_run(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
}


compilation works great (see the first program line)
but as soon as i uncomment the iostream library include,
i get a bunch of errors, i'm assuming library conflict.
Anybody else had this problem?

thanks!

Retitled by davido.

Replies are listed 'Best First'.
Re: embedding perl in c++
by PodMaster (Abbot) on Jan 08, 2005 at 07:07 UTC