Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

[Linux][Perl 5.20.1] embedded perl in C application

by soundlord (Novice)
on Mar 31, 2018 at 16:21 UTC ( [id://1212078]=perlquestion: print w/replies, xml ) Need Help??

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

Greetings !!

C application using Perl functions

I did correctly stuff to call a perl function in a C application that was a lot of fun ^^

This application is about to send mails to customers with a snapshot (an image) with a watermark on it
giving the code they would use to access the party they have paid for...
I tried in full C but sending mail with attachment is a real nightmare,
so I decided to keep the application and call Perl functions using well done
modules efficient for mail composing and attachment handling.
The problem is that for the DBI module I got no particular problem to have it xsinit'd (simply linking the DBI.so library)
BUT concerning the Net::SMTP module, I'm stucked, the compiler (gcc 4.8.3 rev 212064) told me that there is no reference to what is behind
boot_SMTP regarding the xs_init code...

newXS("DBI::bootstrap", boot_DBI, file); newXS("SMTP::bootstrap", boot_SMTP, file);
I tried to locate the .so file without success, all I have are the .pm files that the C language
seems not to handle as the Perl does :{
For now my perl source looks like this:
#! /usr/bin/perl use Net::SMTP; use DBI; sub sendmail() { my $this_function = (caller(0))[3]; print "[PERL -- $this_function]\n"; }
The application works without the Net::STMP reference at the use keyword. Can someone could give me a way to solve this ridiculous compilation error ?

Replies are listed 'Best First'.
Re: [Linux][Perl 5.20.1] embedded perl in C application
by Corion (Patriarch) on Mar 31, 2018 at 17:03 UTC

    I don't think you need to bootstrap Net::SMTP at all, because the bootstrap() function is only for XS code.

    At least that is what I get from DynaLoader.

    I think your program should be able to compile, at least if there is Net/SMTP.pm somewhere on the disk or you put a callback into @INC to supply the source code.

      You are right, I don't need to specify Net::STMP in the list at "-e xsinit -- -o xsinit.c -std"... I'm not confident with these techniques, I would try to find some documentation and books... the term "XS code" is completly unknown for me, and I have to dig deeper concerning the "dynamic loading" in Perl... Thank you for your help ^^

        See perlxs in perldoc for some (lots of) info.

Re: [Linux][Perl 5.20.1] embedded perl in C application
by soundlord (Novice) on Mar 31, 2018 at 16:31 UTC
    ADDED
    gcc `mysql_config --cflags` -I/usr/lib/perl5/5.20.1/x86_64-linux-thread-multi -I/usr/lib/perl5/5.20.1/x86_64-linux-thread-multi/CORE -Doff64_t=__off64_t `perl -MExtUtils::Embed -e ccopts -e ldopts` `perl -MExtUtils::Embed -e xsinit -- -o xsinit.c -std DBI` -o ...(lot of stuff)... /usr/lib/perl5/5.20.1/x86_64-linux-thread-multi/CORE/libperl.so /usr/lib/perl5/vendor_perl/5.20.1/x86_64-linux-thread-multi/auto/DBI/D +BI.so `mysql_config --libs` -lperl -L/usr/lib/perl5/5.20.1/x86_64-linux-thread-multi/CORE -L/usr/lib/perl5/5.20.1/x86_64-linux-thread-multi

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1212078]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-24 11:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found