in reply to Embedded perl on windows x64

Note, the lib directory as well as the perl.dll has been copied over to VS output directory from the previously created and installed perl interpreter

That seems a rather odd thing to do. Ensuring that the directory that houses the perl.dll is in the PATH is normally all that's needed.

Is VS2017 community edition suitable for building a 64bit embedded perl interpreter?

I would expect so, but I haven't tested.

If so, are there some recommendations on how to do this?

Yes, perlembed.

If not, might using mingw toolchain create an embedded perl...

Yes.

However, I too strike issues with your C code. Not sure where you got it from, but the current perlembed docs present it slightly differently.
Here's what I get (with mingw built perl-5.30.0) when I use the C code provided by the perl-5.30.0 perlembed docs:
C:\_32\pscrpt\embed>type embed.c #include <EXTERN.h> #include <perl.h> static PerlInterpreter *my_perl; int main(int argc, char **argv, char **env) { PERL_SYS_INIT3(&argc,&argv,&env); my_perl = perl_alloc(); perl_construct(my_perl); PL_exit_flags |= PERL_EXIT_DESTRUCT_END; perl_parse(my_perl, NULL, argc, argv, (char **)NULL); perl_run(my_perl); perl_destruct(my_perl); perl_free(my_perl); PERL_SYS_TERM(); exit(EXIT_SUCCESS); } C:\_32\pscrpt\embed>perl -MExtUtils::Embed -e ccopts -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DPER +L_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANS +I_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -I"C:\_64\perl53 +0_810\lib\CORE" C:\_32\pscrpt\embed>perl -MExtUtils::Embed -e ldopts -s -L"C:\_64\perl530_810\lib\CORE" -L"C:\_64\gcc-mingw-810\mingw64\l +ib" "C:\_64\perl530_810\lib\CORE\libperl530.a" "C:\_64\gcc-mingw-810 +\mingw64\x86_64-w64-mingw32\lib\libmoldname.a" "C:\_64\gcc-mingw-810\ +mingw64\x86_64-w64-mingw32\lib\libkernel32.a" "C:\_64\gcc-mingw-810\m +ingw64\x86_64-w64-mingw32\lib\libuser32.a" "C:\_64\gcc-mingw-810\ming +w64\x86_64-w64-mingw32\lib\libgdi32.a" "C:\_64\gcc-mingw-810\mingw64\ +x86_64-w64-mingw32\lib\libwinspool.a" "C:\_64\gcc-mingw-810\mingw64\x +86_64-w64-mingw32\lib\libcomdlg32.a" "C:\_64\gcc-mingw-810\mingw64\x8 +6_64-w64-mingw32\lib\libadvapi32.a" "C:\_64\gcc-mingw-810\mingw64\x86 +_64-w64-mingw32\lib\libshell32.a" "C:\_64\gcc-mingw-810\mingw64\x86_6 +4-w64-mingw32\lib\libole32.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w6 +4-mingw32\lib\liboleaut32.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64 +-mingw32\lib\libnetapi32.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64- +mingw32\lib\libuuid.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64-mingw +32\lib\libws2_32.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64-mingw32\ +lib\libmpr.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64-mingw32\lib\li +bwinmm.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64-mingw32\lib\libver +sion.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64-mingw32\lib\libodbc3 +2.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64-mingw32\lib\libodbccp32 +.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64-mingw32\lib\libcomctl32. +a"
Now create the executable (embed.exe):
C:\_32\pscrpt\embed>gcc -o embed.exe embed.c -s -O2 -DWIN32 -DWIN64 -D +CONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_ +IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-stric +t-aliasing -mms-bitfields -I"C:\_64\perl530_810\lib\CORE" -s -L"C: +\_64\perl530_810\lib\CORE" -L"C:\_64\gcc-mingw-810\mingw64\lib" "C:\ +_64\perl530_810\lib\CORE\libperl530.a" "C:\_64\gcc-mingw-810\mingw64\ +x86_64-w64-mingw32\lib\libmoldname.a" "C:\_64\gcc-mingw-810\mingw64\x +86_64-w64-mingw32\lib\libkernel32.a" "C:\_64\gcc-mingw-810\mingw64\x8 +6_64-w64-mingw32\lib\libuser32.a" "C:\_64\gcc-mingw-810\mingw64\x86_6 +4-w64-mingw32\lib\libgdi32.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w6 +4-mingw32\lib\libwinspool.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64 +-mingw32\lib\libcomdlg32.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64- +mingw32\lib\libadvapi32.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64-m +ingw32\lib\libshell32.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64-min +gw32\lib\libole32.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64-mingw32 +\lib\liboleaut32.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64-mingw32\ +lib\libnetapi32.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64-mingw32\l +ib\libuuid.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64-mingw32\lib\li +bws2_32.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64-mingw32\lib\libmp +r.a" "C:\_64\gcc-mingw-810\mingw64\x86_64-w64-mingw32\lib\libwinmm.a" + "C:\_64\gcc-mingw-810\mingw64\x86_64-w64-mingw32\lib\libversion.a" " +C:\_64\gcc-mingw-810\mingw64\x86_64-w64-mingw32\lib\libodbc32.a" "C:\ +_64\gcc-mingw-810\mingw64\x86_64-w64-mingw32\lib\libodbccp32.a" "C:\_ +64\gcc-mingw-810\mingw64\x86_64-w64-mingw32\lib\libcomctl32.a"
Now test it:
C:\_32\pscrpt\embed>embed -le "print 'hello';" hello C:\_32\pscrpt\embed>type hello.pl use strict; use warnings; print "hello\n"; C:\_32\pscrpt\embed>embed hello.pl hello
So it all seems to be working as advertised once your C code is modified correctly.

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: Embedded perl on windows x64
by ekopalypse (Novice) on Aug 01, 2019 at 08:16 UTC
    Hi Rob,
    thank you, I'm baffled, because I thought this was from perlembed but the link you provided
    proves I'm wrong, but still 100% sure, that the posted code runs on ubuntu 19.04, strange.

    The code change, partially, did it.
    Now an exception is raised at perl_destruct but let me first check the docs once again,
    maybe I'm still missing something.
    And thanks for the mingw example as well.
    I keep this thread updated.

    Thank you
    Eko
      ... the posted code runs on ubuntu 19.04

      Yes - the C code you posted also works fine for me on Ubuntu-18.04, perl-5.30.0.
      Apparently different operating systems can have different requirements.

      Also bear in mind that requirements across different versions of perl might change.
      The perlembed documentation that I linked to earlier is for perl-5.30.0.
      It might be more pertinent to check the perlembed docs by running perldoc perlembed, as that will give you the documentation for the version of perl that you have installed.

      Cheers,
      Rob
        Thanks for the confirmation and the hint about perldoc utility.
        Very much appreciated.
        Thank you
        Eko