Using Perl with a compiled C library?

I would like to try and use Perl, but I need to communicate with another application that I wrote. I have an interface library that I wrote in C ++, and it contains a socket communication protocol and an interface for setting / receiving parameters in my application.

I would like to use Perl with Apache to serve webpages to configure my application. I need to know how to get Perl to talk to my interface library.

+3
source share
5 answers

Oh Lord, if you are new to Perl. you don't want to look at XS (I'm not new to Perl, and I don't want to look at XS). See Inline :: C or Inline :: CPP for a much softer introduction to C and C ++ calls from Perl. Deeper drilling in the XS interface should only be necessary if you want to start transferring or retrieving complex data structures (and maybe not even then).

use Inline C => Config => LIBS => '-L/<yourlibpath> -l<yourlib>';

$x = my_library_function_that_returns_an_int_or_double($integer_arg,$string_arg);
+7
source
+3

inline-C, Perl , IPC , (, google perl-). / , C/++.

+3

++, Inline:: CPP. h2xs: h2xs --autogen-xsubs. C:: Scan CPAN.

+1

-, , XS - , C perl (. perlxstut perlxs). , , API Perl (. perlapi), , , perl (. perlguts , perl guts). , . :

  • XS = >
  • perlapi = >
  • perl = >
  • = > ouch

++, ExtUtils:: XSpp CPAN. . , ++ .

PS: , . . , XS : Parse:: ExuberantCTags, Math:: FFTW CPAN.

+1

Source: https://habr.com/ru/post/1720937/


All Articles