perl-xs

Using Perl's ExtUtils::MakeMaker, how can I compile an executable using the same settings as my XS module?

爷,独闯天下 提交于 2019-12-22 04:15:09
问题 Given a Perl XS module using a C library, assume there is a Makefile.PL that is set up correctly so that all header and library locations, compiler and linker flags etc work correctly. Now, let's say I want to include a small C program with said XS module that uses the same underlying C library. What is the correct, platform independent way to specify the target executable so that it gets built with the same settings and flags? If I do the following sub MY::postamble { return <<FRAG; target

Calling C function from Perl within embedded C application

依然范特西╮ 提交于 2019-12-18 13:01:27
问题 Ok, this is a very interesting question and there may not be any easy way to do this but figured I would throw this out there before deciding that modifying Perl is my underlying answer. So I've got a C application that calls Perl scripts in an embedded fashion. This all works fine and dandy and it's pretty awesome that I can pass information in and get information back out. HOWEVER, now onto my next conquest; I need to allow my embedded script(s) to be able to call some functions within the

When should you use XS?

你离开我真会死。 提交于 2019-12-11 03:14:58
问题 I am writing up a talk on XS and I need to know when the community thinks it is proper to reach for XS. 回答1: I can think of at least three reasons to use XS: You have a C library you want to access in Perl 5 You have a block of code that is provably slowing down your program and it would be faster if written in C You need access to something only available in XS Reason 1 is obvious and should need no explaination. When you really need reason 2 is less obvious. Often you are better off looking

What is the modern way of creating an XS module from scratch?

帅比萌擦擦* 提交于 2019-12-09 08:00:58
问题 I need to write an XS module for Perl. It is my understanding that h2xs is pretty much deprecated today, what is the preferred method for starting an XS module today? I looked at Module::Starter, but it only handles pure Perl modules. 回答1: No, h2xs is not deprecated. Module::Starter is certainly more convenient if you create many pure Perl modules, but there's no reason to avoid h2xs. I would recommend reading all the way through its doc before using it, though, so that you know what all you

Using Perl's ExtUtils::MakeMaker, how can I compile an executable using the same settings as my XS module?

我只是一个虾纸丫 提交于 2019-12-05 03:32:47
Given a Perl XS module using a C library, assume there is a Makefile.PL that is set up correctly so that all header and library locations, compiler and linker flags etc work correctly. Now, let's say I want to include a small C program with said XS module that uses the same underlying C library. What is the correct, platform independent way to specify the target executable so that it gets built with the same settings and flags? If I do the following sub MY::postamble { return <<FRAG; target$Config{exe_ext}: target$Config{obj_ext} target$Config{obj_ext}: target.c FRAG } I don't get those

What is the modern way of creating an XS module from scratch?

狂风中的少年 提交于 2019-12-03 10:12:02
I need to write an XS module for Perl. It is my understanding that h2xs is pretty much deprecated today, what is the preferred method for starting an XS module today? I looked at Module::Starter, but it only handles pure Perl modules. No, h2xs is not deprecated. Module::Starter is certainly more convenient if you create many pure Perl modules, but there's no reason to avoid h2xs. I would recommend reading all the way through its doc before using it, though, so that you know what all you might want it to do or not do. Personally I just use Module::Starter and add the .xs file myself. It depends

linking to a C shared library using perl XS

…衆ロ難τιáo~ 提交于 2019-12-01 23:36:05
问题 I am new to PERL XS and have a question about calling a shared library (.so) written in Ansi C. I can't seem to find any good examples showing exactly how to do this. I went though the tutorial to get started (Hello World and all that) located here: http://www.lemoda.net/xs/perlxstut/ I would like to modify it to call a function named cpro_supported in a C shared libarary. libpmap.so: extern int cpro_supported(int); Here are some basics: Makefile.PL: use 5.008005; use ExtUtils::MakeMaker; #

Calling C function from Perl within embedded C application

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 08:46:32
Ok, this is a very interesting question and there may not be any easy way to do this but figured I would throw this out there before deciding that modifying Perl is my underlying answer. So I've got a C application that calls Perl scripts in an embedded fashion. This all works fine and dandy and it's pretty awesome that I can pass information in and get information back out. HOWEVER, now onto my next conquest; I need to allow my embedded script(s) to be able to call some functions within the C application that ORIGINALLY CALLED IT. This is important because XSUB would require it to be an