How do I compile a .exe file which I can run on any windows computer?
-
And that's your job to copy it over to the folder of your application.
windeployqt
can't guess where the .dlls are stored. It knows where the Qt dlls are because it's known at installation time, however there's no standard path to look for to get the .dlls. They are not used at all at linking time so it's impossible to know where to look for them. -
@StevenD said in How do I compile a .exe file which I can run on any windows computer?:
I can now launch my
.exe
after runningwindeployqt
and copyingSDL2.dll
to the same directory. However, I would still like to get this down to 1 file.As @SGaist mentioned earlier, the only way to get this down to 1 file is to use static linking. You need to build a statically-linked version of Qt yourself, and then set your project to use the static libraries of Qt and SDL.
-
@StevenD said in How do I compile a .exe file which I can run on any windows computer?:
Right, but how do I build a statically-linked version of Qt?
In summary:
- Obtain the Qt source code
- Add the
-static
option when configuring Qt - Build Qt
Instructions to configure and build are at http://doc.qt.io/qt-5/build-sources.html
An example set of commands is:
> configure.bat -prefix "C:/Qt/MyStaticBuild" -opensource -confirm-license -nomake examples -nomake tests -static
> make
> make install
Remember, using static linking means that your application cannot be closed-source.
I seem to be missing folders or files from the various tutorials I have found.
Which tutorials, and which folders/files?
-
Thanks for the help. I have successfully downloaded the source code, and now have the files that I needed. However, I am having some issues. Mingw is not working.
mingw32-make: *** Error -1 . Stop. mingw32-make: *** Waiting for unfinished jobs....
...and then it hangs forever.
-
@StevenD said in How do I compile a .exe file which I can run on any windows computer?:
mingw32-make: *** Error -1
There should be more info near this line that describes what the problem is. What was it doing just before the error?
Anyway, run
mingw32-make
again and see if it continues from where it last stopped. (It will first scan the files that have already been processed) -
PS C:\Qt-3.0.1\5.9.2\Src> ./configure.bat -opensource -confirm-license -nomake examples -nomake tests -static + cd qtbase + C:\Qt-3.0.1\5.9.2\Src\qtbase\configure.bat -top-level -opensource -confirm-license -nomake examples -nomake tests -static Bootstrapping qmake ... g++ -c -o project.o -DUNICODE -std=c++11 -ffunction-sections -g -IC:/Qt-3.0.1/5.9.2/Src/qtbase/qmake -IC:/Qt-3.0.1/5.9.2/Src/qtbase/qmake/library -IC:/Qt-3.0.1/5.9.2/Src/qtbase/qmake/generators -IC:/Qt-3.0.1/5.9.2/Src/qtbase/qmake/generators/unix -IC:/Qt-3.0.1/5.9.2/Src/qtbase/qmake/generators/win32 -IC:/Qt-3.0.1/5.9.2/Src/qtbase/qmake/generators/mac -IC:/Qt-3.0.1/5.9.2/Src/qtbase/include -IC:/Qt-3.0.1/5.9.2/Src/qtbase/include/QtCore -IC:/Qt-3.0.1/5.9.2/Src/qtbase/include/QtCore/5.9.2 -IC:/Qt-3.0.1/5.9.2/Src/qtbase/include/QtCore/5.9.2/QtCore -I../src/corelib/global -IC:/Qt-3.0.1/5.9.2/Src/qtbase/mkspecs/win32-g++ -DQT_VERSION_STR=\"5.9.2\" -DQT_VERSION_MAJOR=5 -DQT_VERSION_MINOR=9 -DQT_VERSION_PATCH=2 -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL -DQT_NO_FOREACH C:/Qt-3.0.1/5.9.2/Src/qtbase/qmake/project.cpp mingw32-make: *** Error -1 . Stop. mingw32-make: *** Waiting for unfinished jobs....
-
@StevenD said in How do I compile a .exe file which I can run on any windows computer?:
PS C:\Qt-3.0.1\5.9.2\Src>
I tried to build Qt with PowerShell a few months ago, but it failed. I didn't investigate why, but I suspect it's some kind of incompatibility between PowerShell and the old Batch files.
cmd.exe worked for me; see if that helps you.
-
cmd
gives me almost identical output:C:\Qt-3.0.1\5.9.2\Src>configure -opensource -confirm-license -nomake examples -nomake tests -static + cd qtbase + C:\Qt-3.0.1\5.9.2\Src\qtbase\configure.bat -top-level -opensource -confirm-license -nomake examples -nomake tests -static Bootstrapping qmake ... g++ -c -o project.o -DUNICODE -std=c++11 -ffunction-sections -g -IC:/Qt-3.0.1/5.9.2/Src/qtbase/qmake -IC:/Qt-3.0.1/5.9.2/Src/qtbase/qmake/library -IC:/Qt-3.0.1/5.9.2/Src/qtbase/qmake/generators -IC:/Qt-3.0.1/5.9.2/Src/qtbase/qmake/generators/unix -IC:/Qt-3.0.1/5.9.2/Src/qtbase/qmake/generators/win32 -IC:/Qt-3.0.1/5.9.2/Src/qtbase/qmake/generators/mac -IC:/Qt-3.0.1/5.9.2/Src/qtbase/include -IC:/Qt-3.0.1/5.9.2/Src/qtbase/include/QtCore -IC:/Qt-3.0.1/5.9.2/Src/qtbase/include/QtCore/5.9.2 -IC:/Qt-3.0.1/5.9.2/Src/qtbase/include/QtCore/5.9.2/QtCore -I../src/corelib/global -IC:/Qt-3.0.1/5.9.2/Src/qtbase/mkspecs/win32-g++ -DQT_VERSION_STR=\"5.9.2\" -DQT_VERSION_MAJOR=5 -DQT_VERSION_MINOR=9 -DQT_VERSION_PATCH=2 -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL -DQT_NO_FOREACH C:/Qt-3.0.1/5.9.2/Src/qtbase/qmake/project.cpp mingw32-make: *** Error -1 . Stop. mingw32-make: *** Waiting for unfinished jobs....
-
I'd first cleanup to ensure there's no remaining from your old build tentative.
Also, consider doing out of source builds, that will simplify things if you want to build Qt for several architectures or make different static/shared builds.
-
Because you are calling configure repeatedly with different options, so you should cleanup between invocation.
-
@StevenD You should start with fresh Qt source tree and do out of source build as @SGaist suggested.
Out of source means:c:\qt_source mkdir c:\qt_build cd c:\qt_build ..\qt_source\configure.exe... make
So, basically you call configure and make from outside of the Qt source code directory.
In general you should read http://doc.qt.io/qt-5/build-sources.html -
Right, I now have a different problem:
C:\qt_build>..\Qt-3.0.1\5.9.2\Src\configure -opensource -confirm-license -nomake examples -nomake tests -static + cd qtbase + C:\Qt-3.0.1\5.9.2\Src\qtbase\configure.bat -top-level -opensource -confirm-license -nomake examples -nomake tests -static Host platform 'win32-g++' is invalid. Aborting.
-
From a clean source ?
What command prompt are you using ? -
I've tried using
cmd
and PowerShell, in that order. Both give the same ouput.This may be a problem with Windows. I've recently started having... issues with it that are not related to Qt. Random applications suddenly can't run on my pc... I had this pop up with Qt Creator, Cygwin, and some other things.
-
IIRC Windows latest updates may broke things in surprising ways.