4

My VC++ MFC solution includes four project.

  1. Two project build as DLLs
  2. One project build as Static Lib
  3. One project build as exe with using above three libraries.

I need to host this application without CLR support in windows XP. so I use configuration Use of MFC as Use MFC in a Static Library in all four project.

So my question is what should be the C++-> Code Genaration Configuration for each project.

Nayana Adassuriya
  • 23,596
  • 30
  • 104
  • 147
  • Should I compile with /MD or /MT? : http://stackoverflow.com/questions/757418/should-i-compile-with-md-or-mt – Pheonix Feb 18 '13 at 08:41
  • @Pheonix: thank you and I read this. Logically DLL should use /MD and Lib and Exe should use /MT. But my application gets some linking error. `error LNK2005: __encode_pointer already defined in MSVCRT.lib(MSVCR90.dll)`. I think because static lib already include with a MSVCRT.lib. So this is quit conflicts. So I need some direct answer if some one there clearly understand this concept. I think there should be some straight forward rule for this matter. – Nayana Adassuriya Feb 18 '13 at 09:03

1 Answers1

1

Use /MD for all your projects. As is stated in the referenced questions: it is important to be consistent. So: even build your Static Lib using /MD, since it will be used in an /MD executable. When you do this, the linker doesn't try to link two different versions of the Microsoft library (static and dynamic) which resolves the error.

c_k
  • 1,746
  • 1
  • 20
  • 35
  • This solution doesn't work for me. So I just reduce my application for one exe and one Dll for testing purpose. both build as Use `MFC in a Static Library` and `Multi-threaded DLL (/MD)`, but didn't run in windows XP. but running in windows 7 visual studio installed computer. – Nayana Adassuriya Feb 19 '13 at 04:35