Search code examples
c++qtuser-interfacecrypto++

QT and Crypto++ with /MTd


I have two QT 5.5 projects with MSVC2013 32bit compiler. The first is Qt console application and is using crypto++ and this two in the pro file:

QMAKE_CXXFLAGS_RELEASE += /MT
QMAKE_CXXFLAGS_DEBUG += /MTd

The second is Qt widgets application where is dialog based GUI builded. Individually, each starts successfully, but also individually the GUI project with the same additions in the pro file like these above is givving the same old error:

qtmain.lib(qtmain_win.obj):-1: error: LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.obj

Is there way to unite those two projects somehow? Also please explain the meaning and the difference between:

multi-threaded DLL(/MD)
multi-threaded (/MT)

What is the link between dynamic libraries and /MD, and between static and /MT?


Solution

  • qtmain.lib(qtmain_win.obj):-1: error: LNK2038: mismatch detected for 'RuntimeLibrary':
    value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.obj
    

    This is due to mixing and matching C/C++ runtime libraries.

    Crypto++ has four projects: Cryptlib, Cryptest, Cryptdll and Dlltest. To further complicate matters, Cryptlib, Cryptest have DLL-Import configurations re-used by Cryptdll and Dlltest. Once you understand what's going on it makes a lot of logical sense.

    You are linking against non-DLL-Import Cryptlib, and it uses static linking. You need to switch to linking against a dynamically linked runtime library. For that, see Compiling and Integrating Crypto++ into the Microsoft Visual C++ Environment. Its old, but it still applies.

    You should also avoid anything with DLL_Output in its path. Though it uses proper runtime library linking, you are attempting to link against a DLL. The DLL exists for one purpose - as a security boundary for a FIPS 140-2 validated module. Its usually not what you are looking for, and usually the wrong library for the job.

    Because you should also avoid anything with DLL_Output, open Configuration Manager and delete anything DLL related (for exampe, DLL-Import Release). You should also completely delete the Cryptdll and Dlltest projects to simplify your life.