I am getting linking errors when trying to link against msvcrtd.lib. And when linking against libcmt.lib the application crashes. What can I do ?
Answer:
Qt is pre-built against the shared C runtime (MD(d), as this is the only C runtime that can be used safely in an environment where heap-allocated objects are passed around accross DLL boundaries (which is what you do all the time when creating QObjects or QWidgets - you create them in your heap, and usually pass them on as children of other objects so that Qt can take care of deleting them).
If you link Qt against the static libcmt.lib or if you link your Qt applications against libraries that that are built against the static C runtime library then you will get a mismatch of runtime libraries. This means that there are two heaps in use and as a result if objects get passed from one heap to another (i.e. from Qt to the application and vice versa) then memory corruption will occur. You can usually catch this at build time, if you see a link warning about default libraries then this is usually indicative of this problem. The only way to resolve it is to ensure that everything is built in the same mode.
When linking against msvcrtd.lib instead of libcmt.lib, then you might get linking errors reporting two unresolved symbols, "__pctype", and "___mb_cur_max". msvcrtd.lib does contain those two symbols, however they are not automatically located. It is necessary to create a dummy source file that just references those two symbols:
extern "C" { int __mb_cur_max; unsigned short* _pctype; int errno; }