in reply to Re^3: Compiling C program with a Static Perl
in thread Compiling C program with a Static Perl

... But unfortunately I can't find good simple examples on how to get it done. App::staticperl, like I said, is a huge mess that packs over 100 libs in one big Perl based on 5.12. But I guess there's no other way of doing it but by going over that code and see if I can figure it out.

pretend you've never heard of app staticperl. See -Uusedl in https://metacpan.org/pod/distribution/perl/INSTALL and https://metacpan.org/pod/distribution/perl/INSTALL#Adding-extra-modules-to-the-build and perlembed

  • Comment on Re^4: Compiling C program with a Static Perl

Replies are listed 'Best First'.
Re^5: Compiling C program with a Static Perl
by rodd (Scribe) on Sep 04, 2017 at 00:27 UTC
    Thanks, it looks promising. If I understood correctly, I build a static perl with -Uusedl and my dependencies with -Dextras so that they're statically built also. I've just tried to put the YAML::XS module in-Dextras and it didn't build with some mysterious "Failed" CPAN message. So I stuck YAML::XS into the ext/ dir before building it and it worked...!

    ...well, apparently. I'm still getting this error when I test to see if my new static Perl has the module linked to it:

    perl -MYAML::XS -E '' Can't load module YAML::XS::LibYAML, dynamic loading not available in +this perl. (You may need to build a new perl executable which either supports dynamic loading or has the YAML::XS::LibYAML module statically linke +d into it.) at localperl/lib/5.24.2/YAML/XS.pm line 20.

    ...but I'm pretty sure I saw LibYAML being compiled during make (I did make LINKTYPE=static actually). Why is my static perl trying to Dynaload the module??

      I did make LINKTYPE=static actually

      I believe you should run perl Makefile.PL LINKTYPE=static and follow that with a plain make command. See the ExtUtils::MakeMaker documentation

      Cheers,
      Rob
        There was no Makefile.PL, I'm referring to the Perl source make, the one that comes after Configure.