Shared or Statically Linked MFC?

Hi! Everybody.
         While making a MFC application using the App Wizard, in the 5th step (Visual C++ 5.0), it asks ::
=====
How would you like to you the MFC library?
1). As a shared DLL?
2). As a statically linked library?
=====

What are these options and how can they affect the development of my project? Also when can I use them (i.e. are there any restrictions on when can I use one method over the other and vice-versa).
NoviceAndGoodAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LischkeCommented:
Hi Novice,

you should ask this question in the C forum, this is more appropriate. We are talking here about Windows programming.

Ciao, Mike
0
KangaRooCommented:
There is an MFC forum.
Statically linked means that the linker will add all the MFC functions that your programm uses to executable itself.
Dynamically linked means that Windows will link the MFC functions from a DLL (dynamic link library).
Several different programs can share one Dynamic Link Library, which theoretically means that less executable code needs to be installed on the users computer (if I look in my system directory this approach seems to have failed...). The disadvantage is that you have to ensure that those DLL's are installed on the user's computer.

0
mikeblasCommented:

 Lischke> you should ask this question in the C forum, this is more
 Lischke> appropriate. We are talking here about Windows programming.

Why?  MFC programming _is_ Windows programming!

 NoviceAndGood> What are these options and how can they affect the
 NoviceAndGood> development of my project? Also when can I use them (i.e.
 NoviceAndGood> are there any restrictions on when can I use one
 NoviceAndGood> method over the other and vice-versa).



Most books on MFC (like mine) cover this topic at length. So does the online documentation.

To summarize:

Linking Statically Benefits:

+ you don't have to worry about installing MFC*.DLL
+ you don't have to worry about other apps overwriting MFC*.DLL under you and breaking you
+ your app's working set is generally smaller

Linking Statically Minuses:

+ your app's executable image is generally much larger

Dynamic Linking Benefits:

+ can use MFC in DLLs and communicate MFC objects across the app/DLL boundaries
+ can write OLE Controls with MFC. (Doesn't require dyanmic linking anymore in VC 6)
+ any fixes to MFC are automatically reflected in your app without a recompile--just update the MFC DLLs.

Dynamic Linking Minuses:

+ updates to MFC that aren't binary compatible may break you
+ if some OLE component you load dynamically links to another version of MFC, you might end up with more than one MFC in your executable--which is an amazing waste.

..B ekiM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mikeblasCommented:
Also, I should point out that, if you're planning a system involving an EXE and some DLLs, you'll save working set by linking to a shared version of MFC.

If you have YOURAPP.EXE, 1.DLL and 2.DLL, all using MFC, you'll have these things in memory if you statically link:

   YOURAPP.EXE + static MFC
   1.DLL + static MFC
   2.DLL + static MFC

If you dynamically link, you'll just have this:

   YOURAPP.EXE
   MFC.DLL
   1.DLL
   2.DLL

At some point in these cases (usually pretty quickly--for only 2 or three DLLs) dynamically linking will be cheaper.

..B ekiM
0
NoviceAndGoodAuthor Commented:
Thanks mikeblas.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.