static linking of standard QT libraries - qt

I am trying to build an QT application with version 5.4.
and when ever I am trying to run the exe on a different machine where QT is not installed I am getting below error "The program cannot start because QT5core.dll is missing from your computer, Try reinstalling the program to fix this problem".
and when I copied QT5core.dll with the exe in a machine where QT is not installed its working fine.
Is there any way that I can link QT5core.dll with the exe statically so that whatever place I run this exe it should not ask for any dll.
Thanks,
Tushar

You can build a standalone version of your Qt application so that it doesn't have any library dependencies at runtime. Be warned though: this can greatly expand the size of the .exe generated and the compilation time. Have a look here:
https://wiki.qt.io/Build_Standalone_Qt_Application_for_Windows
and here:
https://wiki.qt.io/How_to_build_a_static_Qt_version_for_Windows_with_gcc

Related

Qt The application was unable to start correctly (0xc000007b)

Am trying to compile project found at uconfig, I managed to compile the application successfully using 32bit version mingw, yet when I run the .exe I get this error The application was unable to start correctly (0xc000007b), I moved all the required DLLs required to exe path but still getting same error,
on the other hand, the application starts in debug mode in Qt creator normally
After searching ... the reason was I had another verion x64 of Qt installed and /bin was added to system path. this resulted in conflict between DLLs generated from Qt and ones found in the System path
I fixed the same problem by running them as adminstrator (properties/compatability/Run as Admin)

CLion run configuration Qt project on Windows, Linux, Mac

I am setting up Qt using CLion and build project successfully.
But the problem comes when I try to run it, which it does not run because it can't find the Qt Library.
When using QtCreator, I don't need to setup anything to run Qt project (it does automatically). So, how QtCreator run the project? So I can achieve it on CLion?
Already set PATH to Qt bin, but it does not work.

Build Qt projects using static build

I have created a program in Qt using Qt Creator. When I open it, the message appears "The program can't start because Qt5Cored.dll and Qt5widgetsx.dll is missing from your computer. Try reinstalling the program to fix this problem."
copy required libraries from you Qt installation to the directory of executable.
Have you really got a static compiled version of Qt? and are you statically compiling your project?... if so your output executable will be around 30-40mb.... and it won't be asking you for dlls.
However it looks like you have a dynamically linked output, in which case you need to find all the DLLs that your projects uses. You can get these from the folder:
<installpath>\Qt\5.5\mingw492_32\bin for example (different if you use linux / msvc)
Keep running the program and grab each dll it complains about... or use somthing like dependency walker (a free executable you can find online) to help determine which DLLs you need.
You probably need (For windows, using mingw):
Qt5Widgets.dll
Qt5Gui.dll
Qt5Core.dll
libwinpthread-1.dll
libstdc++-6.dll
libgcc_s_dw2-1.dll
Or the debug version in your case which end in "d" e.g.: Qt5Core.dll (release), Qt5Cored.dll (debug). Note versions may be different for your installation version. Copy these files next to your executable. OR include <installpath>\Qt\5.5\mingw492_32\bin in your path.
You need to add all the required dlls
C:\Qt\5.2.1\mingw48_32\bin\
to your project. https://forum.qt.io/topic/50705/solved-qt3d-executable-error-qt5cored-dll-is-missing-from-your-computer/2 should solve your problem.

.exe not running through QtCreator and from outside in Qt 4.8.1. issues regarding dll

I have Qt 4.8.1 installed on a windows 7 64 bit OS. I am using opencv and Qt together for my project.
For opencv dll's i gave the necessary path and everything in .pro. Everything was working fine until yesterday.
My code gets compiled successfully, but now when i run, it says that abc.exe executed with code -1073741511.
When I manually run the .exe file from debug or release folder it says that some entry point could not be located in QtCore4.dll.
I tried everything, from setting the Qt & opencv Dlls in %PATH% environment variable to copy and pasting the dlls to the same folder to that of .exe
i hav seen the .exe through dependency walker also and it shows me red color in Link checksum field of QtCore4.dll.
Can anybody help me on this?????
Make sure you are not using (by using i mean copy/add to path) a wrong dll, i mean a dll that was built with a different compiler, example the default (MinGW version) SDK has two versions of QtCore.dll: the correct one (built with MinGW): QT_INSTALL_PATH/qt/bin and one built with some version of VS: QT_INSTALL_PATH/bin (this one is used by Creator and other tools)

Error when executing step 'qmake' on Mac Os

I have just purchased a Macbook (yes I am a complete noob on Mac though I have some considerable experience with Linux) and I'm trying to build my Qt application on it. I have installed XCode and the Qt SDK but when I try to build my project on Qt Creator all I get is the following error during qmake:
Running build steps for project TimeTracker...
Starting: "/usr/bin/qmake" /Users/raphaelcruzeiro/Documents/Projects/Timely/Widget/TimeTracker/TimeTracker.pro -r -spec macx-g++
Failure to open file: /Developer/Applications/Qt/Makefile
Unable to generate makefile for: /Users/raphaelcruzeiro/Documents/Projects/Timely/Widget/TimeTracker/TimeTracker.pro
The process "/usr/bin/qmake" exited with code %2.
Error while building project TimeTracker (target: Desktop)
When executing build step 'qmake'
Any ideas on what is going on? /Developer/Applications/Qt/Makefile indeed does not exist.
EDIT:
Ok, I know what is going on but I don't know how to fix it. When I ran qmake from the terminal everything went just fine. I believe that Qt Creator is trying to build my application on the Qt directory itself and it does nt have permission for it (it shouldn't anyway).
How do I tell Qt Creator where to build my application? I didn't find it anywhere and setting the DESTDIR variable isn't helping.
THE SOLUTION:
Deleting the .pro.user file made Qt Creator build the application to the directory specified in DESTDIR
THE SOLUTION:
Deleting the .pro.user file made Qt Creator build the application to the directory specified in DESTDIR
I was battling with the same thing. What helped eventually was resetting the default build directory here:

Resources