Including modules in embedded perl with VC++

M

Mr Hyde

Hi guys,

I don't know if you'll be able to help me with this, but I'll give it
a go...

I'm trying to embed some perl in a VC++ program using the following
code:

char *embedding[] = { "", "drawGraph.pl", "0" };
my_perl = perl_alloc();
perl_construct( my_perl );
perl_parse(my_perl, NULL, 3, embedding, NULL);
perl_run(my_perl);
perl_call_argv("drawGraph", G_DISCARD | G_NOARGS, embedding);

Now this calls the subroutine drawGraph in the file drawGraph.pl ok if
there are no modules being included. However as soon as I include the
line
use GD::Graph::bars;
it crashes. I'm assuming it has something to do with what is described
on this page:
http://www.monster-submit.com/resou...erlembed.html#Using_Perl_modules_which_themse
however I have been unable to implement that solution. After adding
the code thus:

#ifdef __cplusplus
# define EXTERN_C extern "C"
#else
# define EXTERN_C extern
#endif

static void xs_init _((void));

EXTERN_C void boot_DynaLoader _((CV* cv));
EXTERN_C void boot_Socket _((CV* cv));

EXTERN_C void
xs_init()
{
char *file = __FILE__;
/* DynaLoader is a special case */
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
newXS("Socket::bootstrap", boot_Socket, file);
}

When compiling I get the error:

linkage specification contradicts earlier specification for 'xs_init'
D:\......\PerlThing\PerlThingDlg.cpp(187) : see declaration of
'xs_init'

followed by two:
error C2664: 'Perl_newXS' : cannot convert parameter 3 from 'void
(struct cv *)' to 'void (__cdecl *)(struct interpreter *,struct cv *)'
None of the functions with this name in scope match the target
type

I have been unable to find where to go from here. I don't really
understand what's going on, and I haven't been able to find a resource
that explains this. Is there an easier way around this? Is there
something I should have read up on before posting?

Thanks guys,

Hyde
 
M

Mr Hyde

I realise that this is probably more a VC++ issue, however I thought
I'd give it a go with you guys anyway, maybe one of you has come
across this before.
 
C

castillo.bryan

I don't know if its a problem or not but the xs_init function looks
different, when described in perlembed.

static void xs_init (pTHX);

EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
EXTERN_C void boot_Socket (pTHX_ CV* cv);

EXTERN_C void
xs_init(pTHX)
{
char *file = __FILE__;
/* DynaLoader is a special case */
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
newXS("Socket::bootstrap", boot_Socket, file);
}
 
M

Mr Hyde

I don't know if its a problem or not but the xs_init function looks
different, when described in perlembed.

static void xs_init (pTHX);

EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
EXTERN_C void boot_Socket (pTHX_ CV* cv);

EXTERN_C void
xs_init(pTHX)
{
char *file = __FILE__;
/* DynaLoader is a special case */
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
newXS("Socket::bootstrap", boot_Socket, file);
}

Actually, that did help, thank you! After changing EXTERN_C void
xs_init(pTHX) to static void xs_init(pTHX) to match the prototype,
the program compiled. It's crashing now, though, when I run it. I'll
investigate it and get back to you. Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top