I'm trying to deploy my simple Qt project like a hello world.
I build it successfully and can also execute it on Qt-Creator. However, I can't execute the binary directly in the release folder due to some shared library errors.
So I just copy some essential librarys to the release folder such as qtcore.dll and qtgui.dll, but I can't still execute it.
How can I deploy my simple Qt project? Is there an another step to deploy it?
You also need to deploy the MINGW runtime dll (mingwm10.dll). This file is located in your Qt\2009.5\mingw\bin directory.
Also pay attention to whether your application is compiled in debug mode or release mode. I just made the test with an hello world type application and Qt Creator. In the debug folders, I copied libgcc_s_dw2-1.dll, mingwm10.dll, QtCored4.dll and QtGuid4.dll and it works.
Pay attention to the d in dll names, which stands for debug: QtCore d 4.dll.
See Qt 4.6: Deploying an Application in Windows.
For Qt 5, check this page.
If you don't want to have dependencies with qt/mingw dlls you should compile qt statically as explain here: http://qt.nokia.com/doc/4.6/deployment-windows.html#static-linking.
You may also use static linking, just add this line into the .pro file:
QMAKE_LFLAGS += -static-libgcc
I found the solution here and successfully tested on WinXP with QT creator 2.2.0
Try running dependency walker on it (http://dependencywalker.com/) to see which dlls are missing?
Generally, you won't need to move those Qt libraries into your local folder since the Qt installation should've added those libraries into your path.
One possibility is that you built debug, and the Qt debug dlls are named differently
copy all the qt dlls to your windows directory directly "C:\Windows\" and there will be no qt dll error
100% working and simple
nb: do not create a qt dll folder in your windows directory post them as they are
Related
In Windows, I have a CMake build under Qt that locates, via a find_library command, an A.lib file that is in a separate directory relative to its A.dll file. The A.lib file is then linked using a target_link_libraries command.
As far as the build goes, CMake has no problem not having the symbols in the .lib file defined until runtime.
At runtime, I use windeployqt to successfully assemble all dependent libraries (indluding the A.dll file) into a separate deploy directory from the build directory, and I'm able to run there just fine.
However, to run via Qt's debugger, Qt runs the executable from the build folder rather than the deploy folder. By default, Qt attempts to add the build library folders to the PATH variable as well. Admirably, it also attempts to scan dependencies such as the Qt libraries and the path to A.lib and adds them to the PATH as well. Unfortunately, it does not add the path to A.dll, resulting in a failed DLL dependency error in the launched thread.
I can easily get around this by adding the path to A.dll to the PATH in Qt's run section of the Project tab. However, I'm curious, is it possible to make Qt catch this dependency via some CMake command and automatically add A.dll to the PATH, similar to how it caught other dependencies correctly? I'm not sure how Qt attempts to find dependencies, but in a previous QMake iteration of the build, the path to A.dll was appended automatically.
As of Qt 7.0.1, Qt added a workaround that allows the user to add dll paths to CMake via a target_link_directories command and have those parsed by Qt from the Cmake file-api to add to the PATH variable in Windows.
This fix is in Qt Creator 7.0.1, see the change summary here:
https://codereview.qt-project.org/c/qt-creator/qt-creator/+/404290
And the issue prompting this change on the official Qt website (which is where I should've looked first):
https://bugreports.qt.io/browse/QTCREATORBUG-27201?workflowName=Qt+Bug+Tracking+v2.4&stepId=8
It should be noted that a workaround for this issue was added to Qt Creator at an earlier point (I'm not sure exactly when) that looked one directory above the \lib folder for a \bin folder (see the code that implements this workaround, and performs the CMake file-api queries in general here).
The latter workaround happened to not work for my particular MSVC-built library folders, since there the lib and bin folders are themselves in folders with architecture and OS information, with a common parent three and two folders above, respectively.
Updating Qt Creator to 7.0.1 and using the target_link_directories command solves this issue.
After having enough in searching and reading peoples questions that had the same problem as i have and trying allot of solutions that doesn't seems to help, I'm posting my question.
I want to run my project- qt application, it ran well when i built it on qt4.8.1 32bit and 5.1.1 64bit. now i want to run it on qt5.3.0 32 bit. i installed qt open source with the following configuration:
qt 5.3.0 msvc2010_opengl 32bit.
Since my projects is using qt solutions- qt single application and qt service, i downloaded the packeges, built it in the new environment and placed them in qt/qt5.3.0/5.3/bin and qt/qt5.3.0/5.3/lib.
(I mention this last detail because a simpler qt project that doesn't use these dlls- service and single application runs well in my environment).
Well, when I run my application from qt it doesn't run. When i run the exe file from the release folder i get the following error:
This application failed to start because it could not find or load the qt platform plugin "windows". reinstalling the application may fix this problem.
I tried all creative ideas:
note: I see that automatically the build arainged the release folder with the folowing struck:
plugin folder with all plugins in it.
platform folder with the hole list of platforms: qwindows.dll, qminimal.dll...
and also put straightly the dlls: qwindows.dll, qwindowsd.dll
libEGL.dll
libEGLd.dll
qt.conf with the data:
[Paths]
Plugins=C:...\build-____-Desktop_Qt_5_3_0_MSVC2010_OpenGL_32bit-Release\release\plugins
I used the dependency walker that told me that the IEShims.dll is missind, so I brought it to the release folder from: C:\Program Files (x86)\Internet Explorer.
Now the dependency walker tells me:
Warning: At least one module has an unresolved import due to a
missing export function in a delay-load dependent module.
I see that the Qt5core.dll->link checksum member in the dependency is marked with red, and also I see it takes it from:
C:\Qt\Qt5.3.0\Tools\QtCreator\bin
so I bring to the release folder the Qt5Core.dll from:
C:\Qt\Qt5.3.0\5.3\msvc2010_opengl\bin. then I get the following message:
the procedure entry point
?bytearrayToDouble#QLocalePrivate##SANPBDPA_N1#Z could not be located
in the dynamic link library
c:/Qt/Qt5.3.0/Tools/QtCreator/bin/Qt5Gui.dll
so maybe its wrong to do so.
what else can i do???
I want to use Qt in my new project. An installer for my target compiler (VS2010 64bit), does not exist.
I am using Windows 7 64-bit with Qt 5.1.1.
A colleague of mine is also planning on using Qt and has managed to compile it for my target compiler (which he uses as well). He has built it in some directory, say DirA. He graciously gives me a copy of his entire Qt SDK build (binaries, examples, headers, and all), and I copy it to DirB on my machine.
I need it in DirB, because that is where all my 3rd party libraries are installed, and my CMake scripts know how to find them. I also added the Qt bin folder to my path.
Problems ensue. Qt binaries for some reason have the install path (in this case the build path) hard coded within them. So even though the Qt bin folder is in my path (so DLLs are found), Qt's DLL(s) are looking in the wrong place for the windows "plugin". They are looking in DirA, which does not exist on my machine.
So from what I found researching, using a qt.conf file specifying the install path root, is supposed to be the way to go. I add one to my Qt bin dir, and now Qt binaries (assistant, qmake, etc) can run.
But now I build one of the examples. Builds fine. Run the exe, Qt DLLs load, and then it crashes because it can't find plugin directory.
A work-around my colleague and I found that seems to work, is to copy my qt.conf file to the directory my exe resides in. After doing that the exe runs.
But this does not seem right. My exe can find the Qt DLLs, but the Qt DLLs it loads can't find qt.conf. They don't know to look in their own containing folder. I must have qt.conf in my working directory (my exe dir) for it to be found and used.
Does anyone know why this might be happening, and know of a way for me not to be forced to have a qt.conf file in my exe's dir? I can't accept this requires a rebuild of Qt. There must be some other way.
You can put qt.conf into your binary. Using the resource system.
From the Qt docs:
Without qt.conf, the Qt libraries will use the hard-coded paths to
look for plugins, translations, and so on. These paths may not exist
on the target system, or they may not be accesssible. Because of this,
you need qt.conf to make the Qt libraries look elsewhere.
QLibraryInfo will load qt.conf from one of the following locations:
:/qt/etc/qt.conf using the resource system
Or:
Using QApplication::addLibraryPath() or
QApplication::setLibraryPaths(). This approach is recommended if you
only have one executable that will use the plugin.
If you add a custom path using QApplication::addLibraryPath it could look like this:
qApp->addLibraryPath("C:/customPath/plugins");
I am using Qt Creator to deploy my Qt application. On Mac, I'd like to include the required Qt libraries in the .app bundle. Is there any way to do it automatically using Qt Creator? Should I do it using the command-line? In that case, how should I do it?
The macdeployqt command line tool will add all the necessary Qt libraries that your Qt project references.
If you require any other, 3rd party libraries, you'll need to copy these manually and set the paths to them using the install_name_tool command.
You can check which libraries your application references using the otool command. For example: -
otool -L MyApplication.app/Contents/MacOS/MyApplication
For Qt Creator, I tend to write a script that adds the necessary libraries and calls macdeployqt and then under Projects, add a build step which calls the script.
An example script that would just add the Qt libraries would look something like this: -
#!/bin/bash
pwd
echo Copying QT libraries...
macdeployqt ./MyApplication.app
You can simply run macdeployqt foo.app. Qt Creator does not support this feature off-hand either. However, you can inject custom commands into your process in the QtCreator project settings.
It does not support QML just yet though. There are patches under codereview where it is coming. See the following link for details:
https://codereview.qt-project.org/#q,status:open+project:qt/qttools,n,z
Note: macdeployqt should not be used for usual development and debug! It should be only used when deploying. Otherwise, it is executed each time for building even if you just recompile the code due to a minor change for testing. This can slow down that process, but as for deploying, it should be alright.
On QT6 I was able to do it entirely within QT Creator:
In Projects/Build, add a custom build step after 'make' (probably only want to do this for your 'release' configuration):
Command: %{Qt:QT_HOST_PREFIX}/bin/macdeployqt
Arguments: %{ActiveProject:BuildConfig:Path}/%{ActiveProject:Name}.app - qmldir=%{ActiveProject:NativePath}
Working Directory: %{buildDir}
I was able to test it by airdropping the resulting .app onto my test machine.
reference: https://doc.qt.io/qt-6/macos-deployment.html#macdeploy
I'm having some trouble installing and configuring qt on my vista laptop.
I'm trying to setup a development environment on my laptop where I compile from the command line, because that's how the environment is setup on my university's linux machines, so I don't want to tie myself to some IDE .. (plus, real programmers use the command line!)
I haven't used the command line before for C++ development, it was all MSVC, so now I'm having a bit of trouble.
I'm still using MSVC, but from the command line. I practically have no idea what's going on, I just know that I have to run:
qmake
nmake
to compile my code!
I downloaded the opensource version of qt, and did the configuration, and tried a simple qt application (from a tutorial) and it worked, it compiled and executed pretty much as expected.
Now, when I decided to run another project that uses opengl, I got the following error:
fatal error C1083: Cannot open include file: 'qgl.h': No such file
or directory
I'm not sure where does the compiler look for header files, and I didn't copy any header files anywhere, I assume that configure.exe worked its magic somehow and added the include directory to one or more enviroment variables or to some registery location or whatever other peculier places that the MSVC compiler searches for to find include directories.
However, what I did was search my C:\qt\include\ folder to make sure that qgl.h exists, and sure enough there it was. so why can't nmake find it?
I think the actual solution to this is in your pro file:
QT += opengl
If you want to stay with the command line anyway (plus use it on a linux box later / parallel) I'd suggest at least trying out the MinGW version of Qt. I'm using it regularly, and besides of the non-existance of a GUI it works pretty well. Using MinGW also has the advantage that you can simply download and install the MinGW edition of Qt and don't need to reconfigure or recompile anything.
Also, trying out QtCreator might be interesting. It's still beta and requires the beta Qt 4.5 but it's a nice small IDE that integrates nicely with gcc.
Two potential solutions (they solved issues at my workplace)
Do you have qt include and bin folders in the PATH variable? I think the doc says only one of these is needed, but one of the students had Vista and putting the other in the PATH variable solved a "Cannot open include file" problem.
If you're using MSVC did you run configure and nmake from the Visual Studio command prompt? We had problems when using the bare windows Command Prompt because the VS one adds a lot of temporary environment variables to the configure process.
Good luck
Install the complete Qt SDK for Windows which includes Qt 4.6 SDK, Qt Creator 1.3, and MinGW.
It will also install "Qt Command Prompt" launcher that you can use to build Qt apps from the command line.
I'm sure you're more familiar with MSVC than MinGW, as I do too (I've been using MSVC 6.0 to MSVC# 2008 for developing .NET apps).
But try MinGW with Qt and I think it's better for long term. I do some C++ development on Linux too so getting familiar with MinGW will be beneficial for you in cross-platform C++/Qt development.
For more info, see Installation of Qt 4.6 SDK for Windows.
Qmake generates Makefile from *.pro file located in current directory. It has qt path compiled in. Type "qmake -v" to see it. You can't move qt's dir after compiling it. If You haven't moved it, first maybe try to install Qt following instruction from INSTALL file. Good luck.
The opensource version of Qt does not provide profiles (mkspecs in qt terms) so qmake can generate nmake (msvc) compatible makefiles.
You have to use mingw/gcc.