QT building project -- static build - qt

I am new to QT. I have just installed Qt 4.7.4 (32 bit) which uses mingw compiler. I have few questions.
Please try to answer these :--
I have created a gui application in QT creator. With build configuration For each QT version one debug & one release now it created a build folder geny-build-desktop-Qt_4_8_1_for_Desktop_-MinGW_Qt_SDK__Debug
Inside this folder three makefiles are there :---
Makefile
Makefile.Debug
Makefile.Release
Inside this folder two folder are there :---
debug ---> contains compiled .exe file
release ---> empty
Q-1> How can I change settings in QT creator to compile my project for the release build ?

On the left toolbar of Qt Creator you will find the button to set the build for your project, set it to release.
With your settings a folder named geny-build-desktop-Qt_4_8_1_for_Desktop_-MinGW_Qt_SDK__Release will be created with a release subfolder in it, containing your compiled binary.
Anyway, it doesn't have to do with static build, it is simply a release build of your binary, still depending on Qt dynamic libraries. The difference is that the debug build is linked to the debug libraries (for example: Qt5Cored.dll), while the release build is linked to the release libraries (for example: Qt5Core.dll).
Release builds are usually optimized and don't include debug symbols, so they are also smaller.
If you think about static linking Qt to your program (i.e. getting a binary which not depends on Qt dynamic libraries) you should be aware that you should get a commercial license.

Try using the CTRL + T combination.

Related

Qt.labs.plarform is not installed only in release mode

I am using FileDialog from Qt.labs.platform 1.1 on win 10 in Qt creator, compilator I use is Desktop Qt 5.15.2. MinGW 64 bit.
In the debug mode is working everthing fine but when I change to release mode I get following error in from the compilator:
QQmlApplicationEngine failed to load component
qrc:/main.qml:6:1: module "Qt.labs.platform" is not installed
I tried things like clean and rebuild or restart the computer and also change the number of import version but nothing helps. Any ideas how to solve that, please?
Check folder, where you are building your release (where *.exe is generated):
does it contains some Qt's *.dll's?
If yes: there is two ways to resolve your problem:
Remove all Qt *.dll's and run your application from Qt Creator (then Qt Creator will take all Qt *.dll's from folder, where Qt is installed).
Or add all needed Qt *.dll's with correct folder structure to folder with your release *.exe (to do it for Windows release use windeployqt tool: https://doc.qt.io/qt-6/windows-deployment.html )
Why you have such error from the compilator?
Because you have some Qt *.dll's in your release folder (beside the *.exe), but not all needed (e.g. you have only Qt6Core.dll). So Qt Creator will find this dll and will try to find other dll's in your release folder. Qt Creator will not check its installation directory to get dll's.
But if you have no Qt *.dll's in your release folder, then Qt Creator will find them in its installation directory.

mingwm10.dll missing in the bin folder

I was trying to create a exe file of my Qt project.
I found this post: How to create executable file for a Qt Application?
and realised that i dont have a mingwm10.dll file in that directory.
Are there any other ways of creating a exe file or any other location where mingwm10.dll might be located?
I am using qt 5.6.
mingwm10.dll is a runtime file for the MinGW.org toolchain. Qt moved towards a MinGW-w64-based toolchain (which is essentially an expanded and newer implementation of the Win32 headers and import libraries), which doesn't have this runtime dependency. Ignore it, you don't need it. You might need the libgcc and libstdc++ DLLs though, but that's the same with any (non-statically built) toolchain.
Note you can use the windeployqt utility to automatically copy over all runtime depencies of an executable. You can enable it by adding windeployqt to CONFIG if you're using qmake, or you could just run it yourself:
windeployqt my_app.exe
This command will copy all DLLs (including the Qt platform plugins etc.) so that the application can be run by e.g. double-clicking, instead of only in the specific environment of an IDE.

Qt deployment; the procedure entry point ... could not be located

I have ported an existing Qt4 application Qt5 and added some extra (simple) functionality to this application.
The old application came with
libgcc_s_dw2_1.dll
libusb-1.0.dll
mingwm10.dll
QtCore4.dll
QtCored4.dll
QtGui.dll
Now, from QtCreator I am able to run my modified application, but problems occur when preparing deployment. I have used dependancy walker on my .exe and included a load of DLL's in my executables directory.
icudt51.dll
icuin51.dll
icuuc51.dll
IEShims.dll
libgcc_s_dw2-1.dll
libGLESv2.dll
libstdc++-6.dll
libusb-1.0.dll
libwinpthread-1.dll
mingwm10.dll
Qt5Core.dll
Qt5Cored.dll
Qt5Gui.dll
Qt5Guid.dll
Qt5Widgets.dll
Qt5Widgetsd.dll
QtCored4.dll
(Yes, the project size is now extremely large due to the DLL's, but in my use case this is not an issue.)
And finally it didn't complain about missing DLL's. The error message posted when trying to execute the .exe is:
The procedure entry point ?testBit#QBitArray##QBE_NH#Z could not be located in the dynamic link library Qt5Core.dll
I have never tried executing a Qt application outside Qt Creator, so I have really no idea what to do.
If it helps:
Under Projects-> qmake build config : Release -> Effective qmake call I have
qmake.exe D:\Product\test_util.pro -r -spec win32-g++
If any more information is required to make anything more clear, please leave a comment about it.
I had the same problem on Qt 5.4.2 after slightly modifying my code to add new functionality depending on OpenGL. What I did was use Qt's Window's Deployment tool.
Create a folder and place your binary in it
Using cmd issue the following command depending on which version of binary you have:
windeployqt --release Name_Of_Binary
windeployqt --debug Name_Of_Binary
Depending on which version of Qt Creator you have, you might have to manually copy the lib*.dll's to the directory. This bug is not present in Qt 5.4.2 but was present in earlier versions.

Run .EXE without Qt

[ Solution ]
I want to run my app created with QtSDK on a machine that does not have Qt installed.
I tried to copy the DLL's from the BIN folder to the release of my project, but it did not work.
I tried the following:
I copy all dll's folder d:\Qt\Qt5.0.1\5.0.1\mingw47_32\bin
And pasted it in the folder of my project: d:\projects\mybrowser\mybrowser-build-Desktop_Qt_5_0_1_MinGW_32bit-Release\release
and send it to another computer without Qt
In computer without Qt, I installed vcredist_sp1_x86.exe and tried to run my application browsertest.exe
The following error occurred:
microsoft visual c++ runtime library: this application has requested
the runtime to terminate it in an unusual way
Q: What I really want to know:
How do I run an application built in Qt on other computers (Windows) without Qt installed?
Details:
Qt5.0.1 32bit
mingw 4.7 32bit
QtCreator 2.6.2
Windows 7 64bit.
Intel i5
Folders:
D:\Qt\Qt5.0.1\5.0.1\mingw47_32
D:\Qt\Qt5.0.1\Tools\MinGW
Qt/Mingw:
D:\Qt\Qt5.0.1\5.0.1\mingw47_32\bin\qmake.exe
d:\Qt\Qt5.0.1\Tools\MinGW\bin\gcc.exe
File .pro:
QT += webkitwidgets network core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = browsertest
TEMPLATE = app
RC_FILE = browser.rc
SOURCES += main.cpp\
mybrowser.cpp
HEADERS += mybrowser.h
FORMS += mybrowser.ui
If any information you missed, please let me know.
grateful
To distribute your application you need to copy the DLLs (only the DLLs necessary).
Copy the DLLs necessary from
<DRIVE>:\Qt\Qt<Version_qt>\<Version_qt>\mingw<Version_mingw>\ or <DRIVE>:\Qt\Qt<Version_qt>\<Version_qt>\mingw<Version_mingw>\bin\
eg.: C:\Qt\Qt5.2.0\5.2.0\mingw48_32\ or C:\Qt\Qt5.2.0\5.2.0\mingw48_32\bin
Paste the folder of your application.
Then copy the folders inside of <DRIVE>:\Qt\Qt<Version_qt>\<Version_qt>\mingw<Version_mingw>\plugins
eg.: C:\Qt\Qt5.2.0\5.2.0\mingw48_32\plugins
Paste the folders of your application.
Note: In this example (below), it was necessary to copy DLLs from different places and remove the Debug DLLs (used only to compile in Debug).
Note that the debug dlls end with "d.dll", for example: Qt5Core.dll and Qt5Cored.dll or Qt5Concurrent.dll and Qt5Concurrentd.dll, the ending with "d.dll" should not be copied.
The structure should look something like this (example):
c:\project\app.exe (your app created in Qt)
c:\project\Qt5Core.dll (dll from qt/mingw folder or qt/mingw/bin)
c:\project\platforms (folder from qt/mingw/plugins folder)
c:\project\platforms\qminimal.dll (dll from qt/mingw/plugins/platforms folder)
Only some DLLs the mingw will be needed, so I recommend using the Dependency Walker 2.2
The result should look like this (not all dlls are needed, this can vary by project type):
Thanks to:
+1 for #MartinBeckett, showed me the program to find the DLLs required.
+1 for #WouterHuysentruit, thanks to the application I indicated, I discovered that the contents of the mingw\plugins folder should go straight into the application folder.
#WouterHuysentruit I would consider your answer as correct, but you just said, so I put a simpler explanation. Thanks anyway.
"microsoft visual c++ runtime library: this application has requested the runtime to terminate it in an unusual way"
That's either an ordinary bug, or sometimes a mix of incompatible dlls
Use the (free) depends program on your exe to check which dlls it actually uses - it probably isn't linking all of Qt
Some Qt libs are loaded at runtime from a plugins folder, mostly image formats and database connections - but they woudln't give this error
windeployqt (delivered with QT 5.2+) should do (most?) of the work

Hardcoded QMAKESPEC in Qt Creator?

I installed Qt SDK (Qt framework + Qt Creator) but didn't like the layout of folders so I deleted it (without uninstalling), moved framework in one place and Qt Creator in another and installed Qt framework and Qt Creator separately placing each over the respective old one.
The problem is Qt Creator in Projects/Build Settings/Build Steps keeps showing the old path to the specification file:
-spec c:/qt/2009.03/qt/mkspecs/win32-g++
Setting QMAKESPEC environment variable either in the system or in Projects/Build Environment doesn't change anything.
How can I force Qt Creator to see and use new location of the specification file?
This does not fully solve the issue but if you add '-spec' (without quotes) in the additional arguments box in build steps -> qmake, then it removes the win32-g++ argument.
NOTE: I have NOT been able to build the project after doing this (i changed it to win32-icc and win32-msvc2008 as i have both the intel c++ compiler and VS2008) but the build fails with the error ---- "*** MIssing Separator. Stop." in the makefile
I don't have Qt Creator installed, but I suppose it may store this setting somewhere on filesystem, look in your %HOME% or %APPDATA% for directories associated with Qt Creator and search the files inside for this path.
Have you tried going into Projects->Build Settings->General and clicking on the "Manage Qt Versions" and making sure that everything there is all correct?

Resources