The MSVC builds of Metakit have always been a source of conflicts. Here is some additional information which may help with tracking down and resolving build conflicts:
There are 3 different library builds:
- Universal: #define q4_UNIV 1 - STL: #define q4_STD 1 - MFC: #define q4_MFC 1
The choice determines how strings and collections are implemented.
Libraries can be built either as static library, or as DLL:
- Static: // nothing - DLL: #define q4_KITDLL 1
There is some logic in "mk4.h" and in "header.h" to build as DLL when using MFC as DLL.
Code can be compiled with assertion checking enabled or disabled:
- Release: // nothing - Debug: #define q4_CHECK 1
This option is only used in the library build, not in the public "mk4.h" header, but mixing debug and release code (i.e. between the app and the Metakit library) is not possible because different runtime support libraries are expected by MSVC. This is the most frequent cause of problems, and is caused entirely by MSVC.
Inlining small member functions generates faster code at the expense of code size:
- Inlined: #define q4_INLINE 1 - Normal: // nothing
This option must match between apps and the library, because otherwise function will either be undefined or defined twice.
For completeness, it should be mentioned that MSVC lets you compile static libraries with the runtimes linked in either as DLL or statically. The problem is that one cannot build a static lib with static runtime linkage and then use that library in an app which chooses to build with dynamic runtime libraries. To make matters even more complex, there is a choice between single- and multi-threaded static runtime libs.
Metakit has not been tested exhaustively with these dozens (!) of combinations, but all problems reported so far have always turned out to be caused by mismatches in these settings.
Here's a checklist you can use to make sure the Metakit library and your application will link and work together:
- same library model (UNIV/STL/MFC) - link with static Metakit and static runtime, OR link with Metakit as DLL, and runtime as DLL (MT) - link release versions, or debug versions, no mix - link with inlining turned on or turned off in both
As of version 1.8.5, the Metakit library model (UNIV/STL/MFC) is no longer part o fthe public "mk4.h" header, meaning that more combinations should in principle be possible. It should for example be possible to use the universal build of Metakit in an MFC-based application. This has not really been tested - your mileage may vary...