How can I modify my Makefile.PL to have a Makefile which can make
cc -o test.o -c test.c `perl -MExtUtils::Embed -e ccopts`

Thank

Makefile.PL is a program written using ExtUtils::MakeMaker to generate a
makefile for building a Perl /extension/ module.

ExtUtils::Embed is a module that will generate C code and compile/link options
for /embedding/ a perl interpreter into a C program.

Extending and embedding Perl are two very different, almost opposite ideas.

Since it looks like you have a program called test.c I assume you want to embed
a perl interpreter into that program, and if so you can forget about
Makefile.PL. But in that case what are you asking? You clearly know how to
compile test.c as you have written it in your post, and it is straightforward to
write a makefile to do that if you want to.

So what help do you need from us?

In fact, I have a Makefile.Pl because I am using ExtUtils to generate
c for perl (with xs), but I also need to call a perl subroutine for c !!
I know, it may be not elegant, but it is where I am !!

So I need the Makefile.PL correct to generate the lib for perl
and to compile the c to have it be able to call perl.

So you are embedding a perl interpreter into an XS extension because you need to
call a Perl subroutine from that extension. Is that right? If so then you should
just be able to manipulate the Perl stack and make the call using call_sv or
similar. Take a look at

 perldoc perlcall

for help on this. Or let me know if I'm not understanding you correctly.

So, you do not have any solution for me ?

Yes I do. Let me explain myself a little more.

If you are using the standard perl interpreter to run a program that loads an
extension module you have written using XS then there is no point in linking yet
another copy of the interpreter into the process. All you need to do is to code
the subroutine call in your XS code and it should work. As I said, if you read

 perldoc perlcall

then you should find an example of what you want to do.

Obviously I can't be more specific without knowing more about your requirement.
Are you trying to execute a callback subroutine that was passed in the original
call to your extension? Or is it just that you want to do something that is
neater and more concise written in Perl?

Hi Rob,

It is a bit more complex.

I am a perl routine calling a Cpp routine,
I wrote the xs to interface the call.
I wrote the methods (in Cpp) for the Cpp class.
In fact I need to use a Minuit2 class.
One needs to call a function with is written in perl (I had no doubt that I call perl from Cpp !!)
It looks like that I have to options:
1) It is the class which is called by the perl that is going to call a
subroutine perl (nad I need to compile it to be callable by perl and to be
able the call perl),
2) I compile apart the class which call the perl from the class which
is going to be called by the perl. But this requires one more call:
a Cpp class calling a Cpp class: not very efficient.

The reasons !!
My perl now it a urge program that including plenty of libraries.
The perl subroutine in perl that I need to reuse from Cpp is complex and
a was alot easier to write in perl than in Cpp (and it is easier to
maintain because of the hashes of hashes of hashes ...).
I want to use the MInuit package because it has been ported in perl and
I did not find any package doing such minimization.

I know it is not simple, but it should be doable .

Regards.


---
==========================================================================
 Patrick DUPRÉ                      |   |
 Department of Chemistry            |   |    Phone: (44)-(0)-1904-434384
 The University of York             |   |    Fax:   (44)-(0)-1904-432516
 Heslington                         |   |
 York YO10 5DD  United Kingdom      |   |    email: [EMAIL PROTECTED]
==========================================================================
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/

Reply via email to