Qt - Making qt perform static linking of C++ runtime libraries?
-
I'm currently trying to force my Qt program, which i have made and compiled WITHIN MSVC2010, to compile the C++ dependencies( such as MSVCP100.dll ) statically within the QT program so i don't have to ensure my client has this C++ dll( and to prevent me from having the client install the C++ redistributable in order to get the correct DLL for using my application. I found online where i can simply change the following settings shown below in Qt to make the runtime libraries compile statically with my application. The problem is i have no idea where to go and what to do using microsoft visual studio 2010 in order to change these settings so i can recompile the qt application :( any help is greatly appreciated!
// Settings i need to change to inform QT to imbed C++ RTL inside the qt compiled applications i make
QMAKE_CFLAGS_RELEASE += /MT
QMAKE_CXXFLAGS_RELEASE += /MT
QMAKE_CFLAGS_DEBUG += /MTd
QMAKE_CXXFLAGS_DEBUG += /MTd -
There are numerous thread and wiki articles "how to build standalone Qt app for Windows":http://qt-project.org/wiki/Build_Standalone_Qt_Application_for_Windows. Please find the most appropriate for your case and follow the instruction.
-
If you want to do those things, you MUST also have Qt build as staic lib. You can't only use the MS redistributables linked statically.
-
bq. If you want to do those things, you MUST also have Qt build as staic lib. You can’t only use the MS redistributables linked statically.
Sure you can... but Qt libs will still need shared MS libs... So, it's just doesn't make a sense linking app statically with MS libs and shared Qt libs...
-
It makes a little sense, because you don't have to distribute the MS libs ;-)
-
I may be missing something but to me it looks like the replies have been related to creating static libs to link to the target exe. I too am trying to resolve the OP's issue the way it was posted. That is, retain the shared library DLLs but link the run-time libraries to them. I don't know how to do that as it seems sort of unconventional.
-
[quote author="astodolski" date="1363310054"]I may be missing something but to me it looks like the replies have been related to creating static libs to link to the target exe. I too am trying to resolve the OP's issue the way it was posted. That is, retain the shared library DLLs but link the run-time libraries to them. I don't know how to do that as it seems sort of unconventional.[/quote]
You mean you would like to have Qt DLLs but without MSVC dependencies?
It will not work, Qt supports only MD compilation and not the MT. Quick answer is: you can't compile Qt with MSVC statically compiled into Qt libs. it is because memory allocation for objects is done in different places in Qt(like in QtGUI, QtCore etc...) and this objects then shred between this libraries. MT compiles each DLL with own runtime/memory allocation procedure, you can't allocate memory in one DLL and destroy it in another...