[Interest] Whats the difference between compiling with /MD and /MT?

Thiago Macieira thiago.macieira at intel.com
Fri Oct 9 01:45:51 CEST 2015


On Thursday 08 October 2015 22:51:58 Nuno Santos wrote:
> Thiago,
> 
> Thanks for your reply.
> 
> You have just confirmed me what I have understood from my readings on the
> MSDN documentation. Question:
> 
> When the -static flag is passed to configure what configure does? Because
> from the compile output I can see the /MD flag even when compiled
> statically.

It compiles the Qt code in the form of a .lib which does not produce a DLL. 
But the resulting binary will still link to the MSVC's runtime .dll

If you want to link to the MSVC static lib and avoid the extra .dll 
dependency, you need to modify the mkspec and change to -MT instead of -MD.

> I have manually edited the msvc-desktop.conf and changed from MD to MT. Will
> this make Qt completely independent of the runtime dynamic lib? What are
> the implications of doing this?

Yes.

It means you'll have one big .exe and you have to be careful about using any 
.dlls that link to the runtime .dll. You cannot mix malloc/free from different 
runtimes.

And, of course, the LGPL implications for static linking.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list