General Articles and Tutorials

Statically link with Toolkit Pro when also statically linked to MFC

Author: Kirk Stowell
Platform: Visual C++ MFC

Follow these steps to statically link with the Toolkit Pro Version:

  1. Change your project settings to “Use MFC in a Static Library”. This is found on the “General” tab in your project settings dialog.
  2. Change your “C/C++ Code Generation” to use either “Multithreaded” or “Debug Multithreaded” run-time library.  For release builds use the “Multithreaded” (non DLL) run-time library.  For debug builds use “Debug Multithreaded” (non DLL) run-time library.
  3. Some libraries are incompatible when statically linking to MFC.  On the link tab under input settings you will need to ignore the following libraries.

    For “Multithreaded” add the following to the “Ignore libraries” list: libc.lib, msvcrt.lib

    For “Debug Multithreaded” add the following to the “Ignore libraries” list: libcd.lib, msvcrtd.lib

    See Linker Tools Warning LNK4098 in MSDN for more details.
  4. Add the following line to your application's .rc2 file.  This will link in the toolkit resources so they are available to your application.

    Toolkit Pro:
    #include <XTToolkitPro.rc>
    Command Bars:
    #include <XTCommandBarsPro.rc>
    Docking Pane:
    #include <XTDockingPanePro.rc>
    Property Grid:
    #include <XTPropertyGridPro.rc>