I have a static library built with Visual Studio as a static library (built with Run Time Librbary:Multi-threaded Debug (/MTd)). But when I am using it in my QT project, it says mismatch.
xerces-c_static_3d.lib(XMLString.obj):-1: error: LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in helloworld.obj
Relevant Makefile.Debug
is shown below, as you can see, QT Creator created CFLAGS and CXXFLAGS with -MDd
. Which obviously created the mismatch.
CC = cl
CXX = cl
DEFINES = -DUNICODE -DWIN32 -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_CORE_LIB
CFLAGS = -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zi -MDd -W3 -w44456 -w44457 -w44458 /Fddebug\testbed.vc.pdb $(DEFINES)
CXXFLAGS = -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zi -MDd -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc /Fddebug\testbed.vc.pdb $(DEFINES)
INCPATH = -I..\testbed -I. -I..\testbed\libxsd -I..\..\..\..\Qt\5.9\msvc2015\include -I..\..\..\..\Qt\5.9\msvc2015\include\QtCore -Idebug -I..\..\..\..\Qt\5.9\msvc2015\mkspecs\win32-msvc
LINKER = link
LFLAGS = /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'"
LIBS = C:\Users\intellitix\Documents\testbed\libxsd\lib\xerces-c_static_3d.lib /LIBPATH:C:\Qt\5.9\msvc2015\lib C:\Qt\5.9\msvc2015\lib\Qt5Cored.lib
QMAKE = C:\Qt\5.9\msvc2015\bin\qmake.exe
Excerpt from testbed.pro
As you can see the library is full path NOT the CMAKE style with -L and -l (which makes problems when linking win32 libraries by Visual Studio)
win32:CONFIG(release, debug|release): LIBS += $$PWD/libxsd/lib/xerces-c_static_3.lib
else:win32:CONFIG(debug, debug|release): LIBS += $$PWD/libxsd/lib/xerces-c_static_3d.lib
else:unix: LIBS += $$PWD/libxsd/lib/xerces-c_static_3.lib
INCLUDEPATH += $$PWD/libxsd
DEPENDPATH += $$PWD/libxsd
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/libxsd/lib/libxerces-c_static_3.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/libxsd/lib/libxerces-c_static_3d.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/libxsd/lib/xerces-c_static_3.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/libxsd/lib/xerces-c_static_3d.lib
else:unix: PRE_TARGETDEPS += $$PWD/libxsd/lib/libxerces-c_static_3.a
So my question is,
-Even though the the lib is asked to be linked statically, why QT Creator is complaining it is not compatible with -MDd
, which is dynamic linking. (I tried putting the flag in .pro
file, but it gets overridden)
QMAKE_CFLAGS += /MTd
QMAKE_CXXFLAGS += /MTd
(cl : Command line warning D9025 : overriding '/MTd' with '/MDd'
)
-Tried manually changing CFLAGS
and CXXFLAGS
in Makefile.Debug
but that created even more problems since QMake now tries to link every dependent library statically. Isn't there a way to just static link one library and everything else as dynamic in QT Creator?
Using - VS2017, QT Creator 4.8, QT 5.9, msvc2015 32bit, xerces-c-3.1.4
btw, if linked to dynamic libraries (with lib and dll), everything works perfectly.