[SOLVED] Building Qt 5.4.1 static application for Windows 7?
-
Hi all, I have created a Window 7 based application and managed to get it running under release build. However this application requires external Qt dll files such as "QtCore5.dll" and "Qt5Gui.dll" as well as a "\platforms" folder with "qminimal.dll", "qpffscreen.dll" and "qwindows.dll".
I would like to create a standalone application which does not requires any of the external dll files, such as those mentioned above. I'm currently using
- QtCreator 3.4.0 based on Qt 5.4.1
- Windows 7
- MinGW 4.9.1 32bit (installed via Qt Creator, C:\Qt\5.4\mingw491_32\bin\qmake.exe)
I came across many forums whose solution eventually leads to the url, https://wiki.qt.io/How_to_build_a_static_Qt_version_for_Windows_with_gcc, but it is meant for 4.7.0. A lot of the directories had since changed, removed or renamed. Does anyone have any ideas on how to make it a standalone?
Many thanks,
Johnathon -
Hi and welcome to devnet
Checkout this link for Qt5
In order to build Qt yourself AFAIK you should use the source from this zip or of a previous version. The source as shipped in the prebuilds should not be used for recompilation with a different configuration. -
The steps for building qt 5.4.1 are the same as for qt 4.7.0.
Have a look at the links koahnig gave you. If you still do not know what to do you could have a look at my german tutorial:
https://forum.qt.io/topic/44406/tutorial-qt-5-3-1-für-statisches-linken-builden-mingw
It base on an english tutorials, but it was updated for the 5.3.1 libs. Nothing changed to 5.4.1, so you can look up the path in the german tut ;)If you still have question feel free to ask. I'll see how to help you.
-
@QT-static-prgm Thank you so much for your tutorial. After some modifications on the tutorial steps, I managed to get it working.
I have installed the Qt Creator in C:\Qt\5.5 and the opensource to C:\Qt\5.5_static. When reaching the following step:
- wechselt nun in das Verzeichnis C:\Qt\Qt_5.3.1\ und wählt eure Konfiguration:
- configure -static -platform win32-g++ -opengl desktop -c++11 -make libs
instead of running the command in command prompt in the directory C:\Qt\5.5, i ran the command in the directory C:\Qt\5.5_static. When finished running mingw32-make in the command prompt, there were some compiler errors as below:
C:/MinGW/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-ming
w32/bin/ld.exe: C:/Qt/5.5_static/qtbase/lib\libQt5Qml.a(YarrInterpreter.o): bad
reloc address 0x1f4 in section `.text$_ZN3JSC4Yarr12ByteCompiler7compileEPN3WTF2
0BumpPointerAllocatorE[__ZN3JSC4Yarr12ByteCompiler7compileEPN3WTF20BumpPointerAl
locatorE]'
collect2.exe: error: ld returned 1 exit status
Makefile.Release:86: recipe for target 'C:\Qt\5.5_static\qtbase\bin\qml.exe' fai
led
mingw32-make[4]: *** [C:\Qt\5.5_static\qtbase\bin\qml.exe] Error 1
mingw32-make[4]: Leaving directory 'C:/Qt/5.5_static/qtdeclarative/tools/qml'
Makefile:34: recipe for target 'release' failed
mingw32-make[3]: *** [release] Error 2
mingw32-make[3]: Leaving directory 'C:/Qt/5.5_static/qtdeclarative/tools/qml'
Makefile:94: recipe for target 'sub-qml-make_first' failed
mingw32-make[2]: *** [sub-qml-make_first] Error 2
mingw32-make[2]: Leaving directory 'C:/Qt/5.5_static/qtdeclarative/tools'
Makefile:66: recipe for target 'sub-tools-make_first' failed
mingw32-make[1]: *** [sub-tools-make_first] Error 2
mingw32-make[1]: Leaving directory 'C:/Qt/5.5_static/qtdeclarative'
makefile:220: recipe for target 'module-qtdeclarative-make_first' failed
mingw32-make: *** [module-qtdeclarative-make_first] Error 2I did came across the following post and the author mentioned that some of these errors can be ignored.
Following through to the end of the tutorial, I managed to create a and compile a new project with standalone static build kit. I copied the released version of the executable file onto Desktop and run it, it ran without any errors.
QT-static-prgm, thank you very much for your help.
Johnathon
-
I'm facing another issue right now, I can build a new project as a standalone when I choose the static kit. But when I add the following to the project .pro file:
QT += core gui \
serialportQtCreator immediately prompts an error saying
- Project ERROR: Unknown module(s) in QT: serialport
I have tried some of the suggestions like below:
- Run command prompt and go to C:\Qt\5.5_static\qtserialport
- Run the command: qmake qtserialport.pro
but it still doesn't work.
Has anyone work with QtSerialPort in static Qt?
Thank you
Johnathon