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

I appologise for what may be a noob question, but I've been racking my brain on how to compile in Microsoft VC++ a statically linked perl program.

Here's what I found:

1) Dynamically linked perl works fine.

2) If I change perl510.lib to perl510s.lib, it stil compiles and still ask for perl510.dll when I run the program.

3) If I change Runtime Library setting to "Multi-Threaded" from "Multi-Threaded DLL", and also change the included CRT library from msvcrt.lib to libcrt.lib, I get errors during compilation. If I ran perl-static -V, it shows that it uses the dynamic msvcrt.lib and not libcrt.lib

So there are 2 issues there: Why can't I compile in perl510s.lib and no longer need perl510.dll. Secondly, if I want to staticaly compile the CRT library in the perl library, how do I do that?

Finally, why does perl-static -V show that is uses perl510.lib and not perl510s.lib?!

Greg

Replies are listed 'Best First'.
Re: Compiling with static perl510s.lib
by syphilis (Archbishop) on Dec 02, 2009 at 05:06 UTC
    Why can't I compile in perl510s.lib and no longer need perl510.dll

    I think you'll find that perl-static.exe does *not* need perl510.dll. It's very easy to test - just rename perl510.dll to something else (eg perl510.dll_hide), and then run perl-static -V
    I think you'll find that runs fine, whereas perl -V will crash because perl510.dll can't be found.

    Not that I really understand how things are supposed to work, but it does look to me that things are broken. For example, I would have thought that the Win32 extension would have been built into perl-static.exe, but that's not the case, and any call to load Win32 will try to load the dynamic version (for which perl510.dll *does* need to be found). The mileage you can get out of perl-static.exe without using perl510.dll is therefore very limited, afaict.

    For the record, the static build I tried was with perl-5.11.2, I used MSVC++ 7.0, and the only amendments I made to the win32/Makefile (outside of the usual amendments) was to set "BUILD_STATIC" and "ALL_STATIC" to "define".

    Cheers,
    Rob

      Thanks a lot for your feedback.

      Just to clarify, I'm embeding perl in my own C application, hence why I'm trying to link to perl510s.lib.

      If the Win32 extension is not built into the static library, how hard would it be for someone like me link it staticlaly?

      Greg
        I'm embeding perl in my own C application, hence why I'm trying to link to perl510s.lib

        I don't have much experience with embedding but, normally, people just embed the dynamic perl. Is there a reason that's not a good option for you ?

        If the Win32 extension is not built into the static library, how hard would it be for someone like me link it staticlaly?

        Given that you've received no useful help on this forum, I think you'd be better off pursuing this on the p5p mailing list - where I, for one, would follow the thread with interest. (You may not even have to subscribe in order to post there ... can't remember).
        There should be someone there who understands exactly what's required. I can't even find documentation that explains (with any clarity) what we can rightly expect from perl-static.exe. All I know is that my understanding of the comments in the win32/Makefile doesn't match what I'm actually getting.

        Cheers,
        Rob
Re: Compiling with static perl510s.lib
by Anonymous Monk on Dec 02, 2009 at 04:32 UTC
    If I change perl510.lib to perl510s.lib

    Renaming the file changes nothing, you have to recompile perl.