Reputation: 21
I want to write a programme with VC++ in VS 2008.
And I hope my programme can run on WIN NT, XP, Vista and WIN 7.
And I Hope My programme is only a .EXE file.
I have no idea about the option of "Runtime library" and "Use of MFC"
combination like below:
------------------------------------------------------------------------ | |Multi-threaded | Multi-threaded DLL| ------------------------------------------------------------------------ |Use MFC in a Static Library | A | B | ------------------------------------------------------------------------ |Use MFC in a Shared DLL | C | D | ------------------------------------------------------------------------
I have some question, if you got it, could you please do me a favor. Thanks.
1.The four combination which one is the best choice for me? A, B, C or D?
2.After I test, the choice B will occur compile error, why?
3.When I create a new project or solution in VS, the default option is D, so the D is the best choice for commond programme?
:) Waiting for you prefect answer.
Upvotes: 2
Views: 1929
Reputation: 2241
To get a truly statically-linked executable in MFC, you have to select A. This will tell MFC to compile its classes statically and also to statically link the runtime libraries (I believe it's the MSVCR.dll file). Selecting B is no longer allowed by the compiler, because there is really no use for it. You would use that option only if you want to statically link multiple libraries (your own, perhaps), but you want all of to share the runtime. You end up having memory allocation issues and other nonsense.
So, for your project, select static link and MFC and the runtime, option A.
Upvotes: 0
Reputation: 308520
My own personal preference is to use MFC as a static library so that there are no other dependencies. At the time MFC was written it was common to use shared DLLs to save resources, but in this age of Gigabyte RAM and Terabyte disks a few hundred K won't matter.
Using MFC as a DLL has one advantage that if there's an Service Pack update a new DLL can be installed without replacing the application.
If you're writing a DLL (not an EXE) that uses MFC, it will likely need to share MFC objects with the application and use the application's event loop. In that case you are forced to use MFC as a DLL. I think that's why your combination "B" doesn't work.
Upvotes: 1