CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2000
    Posts
    10

    Compile static or dynamic

    I have to state that I am new to Windows so please dont hate me for this question...

    If I am sending someone a program that uses the
    MFC libraries, is it necessary for me to compile
    with the static library option? Or is there something I can do to send the dynamic .exe version of the program?

    At this time, if I send someone my program (developed with VC6.0), they get a LOAD error like "unable to find MFC4.2".

    Thanks for your support!




  2. #2
    Join Date
    Sep 2001
    Location
    San Diego
    Posts
    2,147

    Re: Compile static or dynamic


    Static or Dynamic defines how the MFC libraries/dlls are associated with the exe.

    If it is statically linked, then the MFC libraries are added to the exe, so they will not be needed externally. You can send someone this one exe, and it will have everything needed to run correctly. The down side of this is that the exe is much bigger, some 200KB+ I seem to recall.

    If dynamically linked, you're telling the exe to try to find the required DLLs when it runs. On your machine, that's no problem, because they are located under the Windows folder (somewhere) and will be found/loaded. On someone else's machine, they may not have the correct DLLs, or even the correct versions that may be needed. These need to be copied to the machine if they are not there.

    I'm sure the next question you'll ask will be why not just statically link everything. Well, there are a few reasons. First off, the exes will be bigger, but perhaps more importantly, some (advanced) things can't be done if the libraries are statically linked. Also, if you distribute your own dlls, help files and other files with the exe, what's the harm in throwing in a couple of MFC dlls too (especially easy when using an installer app, such as InstallShield).

    Anyway, hope this helps,

    - Nigel




  3. #3
    Join Date
    Jun 1999
    Posts
    1,786

    Re: Compile static or dynamic

    If you are using MFC dynamically, you must include MFC DLLs as a part of your installation.
    See Help for details, keyword is 'redistribution'

    Compiling with MFC statically may be an option, but sometime it's hard to do.



    Good luck
    Please rate if you think this response was useful for you

  4. #4
    Join Date
    Apr 2001
    Location
    CA , USA
    Posts
    83

    Re: Compile static or dynamic

    Hi

    my application runs fine when i run using mfc in shared dll. But when i switch to use mfc in static linking it give some linking problems.Im using some external libraries also.

    Any help is greately appreciated,

    Thanks
    shashi




  5. #5
    Join Date
    Sep 2001
    Location
    San Diego
    Posts
    2,147

    Re: Compile static or dynamic


    What linking problems are you getting?

    Show us the error lines produced by the linker...

    - Nigel




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured