How do you static link Qt (/MT) with visual studio 2013?
-
- "This":http://msdn.microsoft.com/en-us/library/ms235460.aspx has some explanation about what can happen with MT.
It also means that if an update (bug fixe or other) to the runtime is provided by Microsoft, your application won't benefit unless you rebuild your application, Qt and all other libraries again with it.
- "Here":https://qt-project.org/faq/answer/why_does_a_statically_built_qt_use_the_dynamic_visual_studio_runtime_librar It boils down to modify the qmake.conf from your mkspec and follow the standard procedure.
-
Alright. That's good to know. Now what are the very specific steps to rebuilding it for static use?
-
The "deployment guide":http://qt-project.org/doc/qt-5/windows-deployment.html shows how to build statically and the other wiki entry I gave you explain the additional step you need to do.
-
OK. The only actual steps I found that applied to me were:
Open a command prompt and run:
cd C:\Qt\Qt5.3.1
configure -staticThen, from qt-project.org:
"Edit the qmake.conf file for your qmakespec. Where it says -MD you need to change it to be -MT"
(That's simple enough except there are 279 qmake.conf files in different directories within the C:\Qt\Qt5.3.1 directory. It's also not clear if this is supposed to be done before the first step.)"For Visual Studio 2005 it is also necessary to change the relevant files in mkspecs/features to remove the call to mt.exe" Yea, this isn't clear at all and needs to be translated into actual steps.
The good news is, if these questions get answered, by the end we'll have an actual step-by-step guide to doing something that, in my humble opinion, should already exist :-D
-
Like written, this flag combination is not supported so there's no reason to have a guide for that.
You have mkspecs for each VS version supported so just go there edit qmake.conf and then configure/build Qt. You have been warned, it will probably break.
-
The version of visual studio should be irrelevant. OpenCV supports what I'm asking just fine and even has the libraries already built for it without caring about what IDE I'm using. I want the same thing from Qt. I don't mind not having the Qt plugin work and I'm not trying to use the Qt IDE. I just want to make the gui portion of my program with statically linked Qt. Is that too much to ask?
-
On the contrary the version of Visual Studio is very relevant, look at the OpenCV binaries, they provide one version for each version of VS they support. They are not compatible between them.
I already wrote what you need to do: take the mkspec for your version of visual studio e.g. win32-msvs2012, edit the qmake.conf in it and replace /MD with /MT and then it's a normal static Qt build like described in the documentation.
-
- There is already a libs folder full of *.lib files at C:\Qt\Qt5.3.1\5.3\msvc2013\lib. Does that mean static compilation has already been done? (That was the case with OpenCV. A forum member thought it had to be rebuilt but it already came with what was needed for an /MT build)
If not:
2. So I would edit the qmake.conf file in:
C:\Qt\Qt5.3.1\5.3\msvc2013\mkspecs\win32-msvc2013 ?- I would change the following lines:
QMAKE_CFLAGS_RELEASE = -O2 -MD
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi
QMAKE_CFLAGS_DEBUG = -Zi -MDd
to:
QMAKE_CFLAGS_RELEASE = -O2 -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
QMAKE_CFLAGS_DEBUG = -Zi -MTd?
-
-
No, on windows static libraries and import libraries have the same extension.
-
First download the sources, then edit that file in the sources
-
Correct
Then build
-
-
I downloaded what was labeled as the source. It is a folder called "qt-everywhere-opensource-src-5.3.1" It seems to be non-specific and not designed for any particular IDE or anything which goes back to my original intuition. Almost every subfolder has a .qmake.conf file and none seem to have any mention of /MD switches. I'm guessing now that we're suddenly switching gears and using the source instead of the VS2013 specific Qt version that downloading the VS2013 version was a waste of time and should be deleted.
- What are the specific next steps after downloading the source?
1a. What or which .qmake.conf files need to be edited and in what very very specific way?
- What are the specific next steps after downloading the source?
-
- Download zip file (yes, the tar.gz is smaller but the line endings won't please windows)
- Uncompress zip file
- Edit qt-everywhere-opensource-src-5.3.1\mkspecs\win32-msvc2013\qmake.conf
- start a VS command line (64 or 32 bit depending on your needs)
- configure Qt with the options you want and -static, if you don't use webkit anywhere, don't build it it'll save you time. Also take extra care of what plugin you will want to use and build them in it will also simplify your life.
- call jom.exe (that you can find in your current Qt install) or nmake
- Enjoy you favorite beverage while Qt's compiling
-
Thank you very much for posting specific steps.
- I do not see a mkspecs folder. What is wrong here? (see attached image)
- Is there a link that outlines all of the different build options?
-
Sorry, they are in qtbase
configure --help will show you what you can do.
I'd also recommend an out of source build so if something goes wrong you don't have to clean the sources.
-
I've done up to step 5 but didn't know what options to use so I just ran "configure -static". Now I need to run nmake but what should the specific commands and flags be?
nmake clean
qmake ?
namke ? -
just nmake, it's like *nix make but from Visual Studio
-
- Is the following error worth worrying about? (it looks like it is trying to run python for some reason..)
- Is it intelligent enough to still try to compile everything else or did it stop and possibly not get to other things that would have successfully compiled?
C:/Users/John/Desktop/qt-everywhere-opensource-s
rc-5.3.1/qtbase/include/QtCore/5.3.1/QtCore -IC:/Users/John/Desktop/qt-everywhere-opensource-src-5.3.1/qtbase/include/QtCore jsapi\qjsengine.h -o .moc\debu
g\moc_qjsengine.cpp
python C:/Users/John/Desktop/qt-everywhere-opensource-src-5.3.1/qtdeclarative/src/3rdparty/masm/create_regex_tables > RegExpJitTables.h
'python' is not recognized as an internal or external command,
operable program or batch file.
NMAKE : fatal error U1077: 'python' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.C:\Users\John\Desktop\qt-everywhere-opensource-src-5.3.1>
-
Sorry, I've been building it for so long that I forgot the requirements.
You'll find "here":http://qt-project.org/doc/qt-5/build-sources.html#windows the requirements as well as a more verbose set of instructions to build from source.
-
The overall goal here is to just be able to have an embedded OpenCV window, buttons, labels, checkboxes, sliders, etc in a GUI for a desktop application. The other requirement is that the desktop application not depend on any DLLs except what always comes with windows.
ActivePerl, Python and Ruby are needed for ANGLE and Webkit respectively. I don't think I need those.. What are the specific flags to bypass those and to just build what I need for what is described above?
-
If you just want the "base" configure and build only qtbase, to avoid ANGLE use -opengl desktop