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

I agree that there's a tool for every job. In my case Perl would be the right tool. The code with LibYAML is just the tip of the iceberg (a proof of concept). Behind my example there is actually a good codebase that I'm not willing to rewrite and that make a single static Perl executable the right choice my use case... 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.
  • Comment on Re^3: Compiling C program with a Static Perl

Replies are listed 'Best First'.
Re^4: Compiling C program with a Static Perl
by Anonymous Monk on Sep 03, 2017 at 21:17 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