I\'m absolutely new to Qt. I\'ve made a program using C++ in Visual Studio 2010 in which I use the external library from Dcmtk. I now want to add a user interface to that pr
In the version of QT 5.5 the variable is QMAKE_CXXFLAGS_DEBUG and QMAKE_CXXFLAGS_RELEASE so the new working solution for QT 5.5 is:
QMAKE_CXXFLAGS_DEBUG += /MTd
QMAKE_CXXFLAGS_RELEASE += /MT
since Qt 5
, adding to your qmake
build script *.pro
file, a configuration like:
CONFIG += static_runtime
will cause qmake
to include the mkspecs/features/static_runtime.prf
file, which should contain the required configurations, something like below:
msvc {
# -MD becomes -MT, -MDd becomes -MTd
QMAKE_CFLAGS ~= s,^-MD(d?)$, -MT\1,g
QMAKE_CXXFLAGS ~= s,^-MD(d?)$, -MT\1,g
} else: mingw {
QMAKE_LFLAGS += -static
}
but as advance warning, note that this may cause some link errors, which make an statement like
"MSVCRT.lib(MSVCRxxx.dll) : error LNK2005: xxx already defined in LIBCMTD.lib(xxx.obj)
", basically because other libraries that you are using are linked with the dynamic CRT library (i.e. they are NOT build with /MT
or /MTd
flag, and you would need to rebuild them with the appropriate flag), for more see this question.
/MT
is a compiler flag. You can specify flags in your .pro file like this:
QMAKE_CXXFLAGS += /MT
Moreover, you probably want to specify /MTd
for debug build:
Release:QMAKE_CXXFLAGS += /MT
Debug:QMAKE_CXXFLAGS += /MTd
A qmake configuration is also available for this.
CONFIG += thread