Quoth [email protected] (Mark Dootson):
>
> Not OS no, as written for part of larger project.
> But if I were to start from scratch to implement the idea, it would end
> up looking something like :
>
> hPerlLib = LoadLibrary( pathToPerlDll);
RunPerl = GetProcAddress(hPerlLib, "RunPerl");
:)
> numopts = argc + 2;
> dynamicargv = malloc(numopts * sizeof (char*));
> dynamicargv[0] = argv[0];
> dynamicargv[1] = (char *)pBufferIncPath;
> dynamicargv[2] = (char *)pBufferScriptPath;
>
> for (i = 1; i < argc; i++)
> dynamicargv[i + 2] = argv[i];
>
> returnval = RunPerl(numopts, dynamicargv, environ);
> FreeLibrary(hPerlLib);
> free(dynamicargv);
> return returnval;
...which is pretty close to what EU::PerlToExe produces, except I use
perl_* instead of RunPerl for portability, and I don't (yet) do anything
clever to locate the dll at runtime. I'm wondering if I should use
RunPerl instead on Win32: do you know if it makes any difference?
Certainly locating the dll by hand rather than allowing the OS to find
it is the right idea (if you want to have a shared libperl at all).
At some point I would like to take a good look at pp's myldr code, to
see if I can't make it do that instead of linking libperl directly. Of
course, this means nicking DynaLoader's dl_*, to get a portable dlopen
interface.
Ben