Static Builds not Working
-
@ed-wright
Ok, so its really not build as static.
Did you follow a guide to make a Qt static version ?
In case, yes, which one ?
Normally, there comes a new kit when you compiled the new Qt verion.
And you need to select that for the app.Also as a note. Using static linking requires a Qt license.
Its not available as open source, unless your app is also open source. ( which seems not to be the case)
Since you seems to be a license holder, there is also the option to get direct support form Qt Company versus this free user forum.Also, you surely means static ? Static means it wont need any DLLs next to exe but all is compiled into the .exe.
If you mean more like standalone. (outside creator)
Then you just need to get the needed Dlls in the same folder as exe and it will run outside creator.
I use this site for info
http://www.tripleboot.org/?p=138 -
@raven-worx Thanks for your reply
- If I uncomment the line CONFIG += static, should this make my project statically compiled?
- Is this a download or do i have to build this. I have a Qt Commercial licence.
- So if i want to statically link QNetwork for example do add QTPLUGIN += qnetwork (i am reading the link you sent as we speak)
@mrjj Thanks again for your reply, I do have a commercial licence but i happy to stay on here if it helps someone else in the future.
What is the process for statically linking Qt into my project?What I ultimately want is a stand-alone application (just an .exe) that i can run to start my application no DLLs
-
@ed-wright
Hi
Then you have to build a static Qt version.
I have seen static pre-build for Qt Device Creation but im not sure
if they have one for Desktop. (I would ask, it takes quite some time to compile
a full Qt unless your pc is epic)
this is a good start read
https://wiki.qt.io/Build_Standalone_Qt_Application_for_Windows
and also
http://amin-ahmadi.com/2016/09/22/how-to-build-qt-5-7-statically-using-msvc14-microsoft-visual-studio-2015/
but first start with
http://doc.qt.io/qt-5/build-sources.html
and make sure you install all it mentions from
http://doc.qt.io/qt-5/windows-requirements.html
perl, and also python i recall. This is a must do or
it will compile for long time and then fail.
Also, use a good pc. Dual core 1.5 ghz slim laptop will take ages. -
Back to your original comment, I manually moved over all the Qt5*.dll from C:\QT\Qt5.10.1\5.10.1\msvc2015_64\bin and then ran windeployqt.exe it now executes.
Changes
It is now the release version
My pro is now changed to uncomment the line "#CONFIG += static"
My C:/QT folder is not currently called this as per your recommendation -
@ed-wright
Ok, so you successfully made a deployment folder.
Good work. Its also handy to have to check out stuff.But its not static as that is some more work before thats possible,
-
@ed-wright
Yes, that is the source code. But there is also Qt 5.11
but i assume you been using 5.10.1 ? ( its perfectly fine)
You will then compile a static version from it.
Make sure to reads docs carefully as else it fails and you been wasting hours looking at it compiling. -
@ed-wright
That is fine. Not an issue. just wanted to be clear up front as the
compiling time is not trivial .) -
I have been trying to compile the static version of Qt now and have run into a few issues.
Following http://doc.qt.io/qt-5/windows-building.html to try to build the
static version of Qt.STEP 1
As i use Qt Creator and i have put the License into the prompt this step is
doneSTEP 2
I already have a directory called C:\QT\Qt5.10.1, but from the downloads page
in my account i also have downloaded (Qt Source Package, Full Framework with
Windows style line endings ) and it is unpacked and located at C:\QT\qt-
everywhere-src-5.10.1, my project is currently using the first path.STEP 3
With the environment variables, in my PATH i have
C:\QT\vs2015\qt5.6.1-64\5.6\msvc2015_64\bin, i do not think this is correct as
i want to be using 5.10.1 with msvs2015 so i think it needs to be.
C:\QT\Qt5.10.1\5.10.1\msvc2015_64\bin is this correct?Anyway, following the guide my file qt5vars.cmd has the following:
REM Set up \Microsoft Visual Studio 14, where <arch> is \c amd64, \c
x86, etc.
CALL "C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\vcvarsall.bat" amd64
SET _ROOT=C:\QT\qt-everywhere-src-5.10.1
SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH%
REM Uncomment the below line when using a git checkout of the source
repository
REM SET PATH=%_ROOT%\qtrepotools\bin;%PATH%
SET _ROOT=NOTE: i am trying to use the downloaded (Qt Source Package, Full Framework
with Windows style line endings) not the normal 5.10.1 build.NOTE2: This produces the following when running in the cmd off the shortcut on
the desktop:C:\WINDOWS>REM Set up \Microsoft Visual Studio 14, where <arch> is \c
amd64, \c
x86, etc.C:\WINDOWS>CALL "C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\vcvarsal
l.bat" amd64STEP 4
Using the Developer Command Prompt for VS2015 i navigate to C:\QT\qt-
everywhere-src-5.10.1and run the following configure -debug -nomake examples -nomake tests -skip
qtwebengine -opensourcei get the following errors
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual
Studio 14.0
\VC\BIN\cl.EXE"' : return code '0x2' -
Okay an update, Still not working but got a little further.
I have added the line:
set CL=/I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt"to the file, C:\QT\qt-everywhere-src-5.10.1\configure.bat
it now progresses further BUT now i get this error:
LINK : fatal error LNK1104: cannot open file 'libucrt.lib'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\link.EXE"' : return code '0x450'
Stop.im trying to find libucrt.lib as we speak
-
Hi
Good work.
I have not seen that one before, but it seems to be related to static linking
https://stackoverflow.com/questions/35805113/visual-studio-2015-run-time-dependencies-or-how-to-get-rid-of-universal-crt -
Adding the following to my configure.bat located in the C:\QT\qt-everywhere-src-5.10.1 directory allowed me to overcome this problem.
set INCLUDE=%INCLUDE%;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt set LIB=%LIB%;C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x86
Onto the next issue now.
I have successfully run the command
configure -debug -nomake examples -nomake tests -skip qtwebengine -opensource -static
The next part of the guide states that the following command should be run.
nmake
Once running it went for a few minutes and then produced the following error
Microsoft (R) Program Maintenance Utility Version 14.00.24210.0 Copyright (C) Microsoft Corporation. All rights reserved. cl -c -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zi -MDd -utf-8 -W0 /Fd..\..\..\lib\qtpcre2d.pdb -DUNICODE -D_UNICODE -DWIN32 -DPCRE2_CODE_UNIT_WIDTH=16 -DPCRE2_STATIC -DQT_NO_NARROWING_CONVER SIONS_IN_CONNECT -DHAVE_CONFIG_H -DQT_NO_DYNAMIC_CAST -DQT_NO_EXCEPTIONS -I. -Isrc -I..\..\..\mkspecs\win32-msvc -Fo.obj\debug\ @C:\Users\T0187208\AppData\Local\Temp\nmF7A.tmp pcre2_auto_possess.c pcre2_chartables.c pcre2_compile.c pcre2_config.c pcre2_context.c pcre2_dfa_match.c pcre2_error.c pcre2_find_bracket.c pcre2_jit_compile.c pcre2_maketables.c pcre2_match.c pcre2_match_data.c pcre2_newline.c pcre2_ord2utf.c pcre2_pattern_info.c pcre2_serialize.c pcre2_string_utils.c pcre2_study.c pcre2_substitute.c pcre2_substring.c Generating Code... Compiling... pcre2_tables.c pcre2_ucd.c pcre2_valid_utf.c pcre2_xclass.c Generating Code... lib /NOLOGO /OUT:..\..\..\lib\qtpcre2d.lib @C:\Users\T0187208\AppData\Local\Temp\nm1B7D.tmp cd corelib\ && ( if not exist Makefile C:\QT\qt-everywhere-src-5.10.1\qtbase\bin\qmake.exe -o Makefile C:\QT\qt-everywhere-src-5.10.1\qtbase\src\corelib\corelib.pro ) && "C:\Program Files (x86 )\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe" -f Makefile ASSERT: "isAbsolutePath(baseDir)" in file C:\QT\qt-everywhere-src-5.10.1\qtbase\qmake\library\ioutils.cpp, line 106 NMAKE : fatal error U1077: 'cd' : return code '0x3' Stop. NMAKE : fatal error U1077: 'cd' : return code '0x2' Stop. NMAKE : fatal error U1077: 'cd' : return code '0x2' Stop.
This is omitting some of the previous command line output that all worked correctly, this is where it crashed.
Do you have any idea?
-
So part of the problem was that my default prefix for the configure command was incorrect.
So going back and running the following worked.
configure -debug -nomake examples -nomake tests -skip qtwebengine -opensource -static -prefix C:\QT\qt-everywhere-src-5.10.1 -redo -recheck-all
Then to Build
nmake
-
Super good work.
Thanks for updating on the way. will be helpful for others.