windeployqt does not work on projects that use qmldir modules - qt

I am trying to deploy an application using the windeployqt --qmldir method. When the command is run from within the folder that contains the executable, all the dependencies are copied and everything appears to go well. Except, when I click on the application file to run the it on a system that does not have Qt installed, it simply will not start. I get the busy mouse pointer for a few seconds and then nothing. No errors or anything. It does start fine on the machine with Qt installed but not on the other. I tried deploying a few of my other projects using the same method and they all worked just fine. Then it occurred to me that it might be the multiple qmldir "modules" that I'm using. So I took a project that previously deployed just fine, added a qmldir module to it and deployed it again, aaaand nothing. Same "not starting" problem. How do I use the windeployqt tool with projects that have multiple qmldir modules? What am I missing? I am using a number of qmldir files, all of which exist within a single qrc resource file that houses all of my application's qml. Here is my project structure and the commands I tried:
-Top_Level_Project_Dir
-GUI_Construction
-fonts
-images
-javascript
-qml
-Construction_QML
-QML_Elements_Directory_1
- a bunch of qml files, some in their own folders
- qmldir
-QML_Elements_Directory_2
- a bunch of qml files, some in their own folders
- qmldir
-Singletons
- Globals
- qmldir
- Menus
- qmldir
-qml.qrc
- GUI Tests
The windeployqt commands that I have tried are:
windeployqt --qmldir C:\QtProjects\Top_Level_Project_Dir\GUI_Construction\qml <location of exe>
That does not work. Also tried:
windeployqt --qmldir C:\QT\5.15.1\msvc2019_64\qml <location of exe>
This made the deploy directory quite large because it copied everything but it still didn't work. Then I tried plugging in the import paths (specified in the main.cpp file using engine.addImportPath()) after the --qmlimport option:
windeployqt --qmldir C:\QtProjects\Top_Level_Project_Dir\GUI_Construction\qml --qmlimport C:\QtProjects\Top_Level_Project_Dir\GUI_Construction\qml\Construction_QML (same for each qmldir) <location of exe>
This also did not work. It just copied all my qml files to the deploy directory, which is something I want to avoid anyway.

Related

Qt6 qt_generate_deploy_app_script plugin DLL copying

Currently I have to manually copy the platforms and imageformats plugin folders to the directory containing the .exe that MSVC compiled. This is very tedious as the output folders often get deleted if you're working on your CMakeLists.txt or changing compilation target.
Now qt_generate_deploy_app_script seems like an official Qt solution to solve this problem, but it does not work.
I have added the CMake bits to my CMakeLists.txt as stated
qt_generate_deploy_app_script(
TARGET HiveWE
FILENAME_VARIABLE deploy_script
NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
I can see some generated deploy scripts appear under build\x64-RelWithDebInfo\.qt, but they do not seem to be run as no DLL folders get copied to where my .exe is.
Am I misinterpreting what qt_generate_deploy_app_script should do or is it simply broken?
If you want to Creat exe in windows From Qt project you should use windeployqt
To Deploy and create Exe output with QT in windows you should follow this way:
put your compiler path in your system path. for example, if you use mingw81_64, you should set it. something like Qt/tools/mingw81_64/bin
copy exe file that provides after building in release mode in one
folder and run mingw81_64 cmd (it has separate cmd) and cd to that
folder path
windeployqt app.exe
you are using Cmake So first create one release output and then use step 3.
This command will get all dll needs for your app and your exe will work .
if you use qml
windeployqt --qmldir (the path of its directory ) app.exe
and also see these youtube videos for more info:
https://www.youtube.com/watch?v=LdSTgR0xJco
https://www.youtube.com/watch?v=hCXAgB6y8eA

How to use extensions

Could someone please explain how one uses the premake extensions. I added the eclipse extension in a directory under my premake installation. And in the premake script I added recuire "eclipse".
Running the script with premake5 eclipse, I get an error module "eclipse.lua" not found.
I added the path of the modules directory to my environment variables.
I'm using premake (premake5) on Windows 8.
Thanks
addons need to reside in a folder. You need to create a "eclipse" folder, then copy all the files in it, and the "eclipse" folder should be located where premake can load it (either next the executable or some other place handled through environment variables)
I got this working by adding the full path to the require statement.
require "C:/premake/eclipse/eclipse"
and running the command as premake5 eclipse
Note: This plugin does not generate project files that one can import into Eclipse.

Qt Release qt.conf

When I release my Qt project, I want to redistribute the QtCore5.dll and Qtxxx.dll files.
How can I make myapp.exe to find them automatically?
The best way of doing this seems to be by editing a qt.conf file placed in the same folder as my executable.
myapp.exe is in c:\myapp\bin folder
The dlls are in c:myapp\common folder
"Better" way is to put your qt.conf into your resources :/qt/etc/qt.conf. This way has highest priority for resolving platform dependencies.
In our project we use cmake to generate necessary qt.conf file: in debug mode we put path to installed Qt binaries and in release - to local (deploy) folder.
Qt5xxx.dll files are linked, so you should place it in same folder, or make them available throught PATH environment variable. If you really want such exotic redistribution system (please, say real reason) - you may create your own platform-specific launcher, that will load necessary .dll's from any path.
Just put all required dll files into the same directory as your executable.
Note, that there are more files to distribute than just Qt*.dll - you will need proper plugin from platforms subdirectory and many more. Read Qt documentation on deploying application under Windows - it will teach you all required files.

Applications works while debugging, but doesn't work when "released"

So, I just made a standard, QtQuick 2 application, it has the default Recangle, Text and MouseArea. So, I just tried to compile the application in release mode, to see what files it would generate, and then I tried opening the application and this happened:
When I resize it, I cans see white space:
However it all works fine in debugging:
I am using Qt 5.0.1 and QtQuick2
Update
So, after running it through Dependency Walker it appears like there are three files missing: qt5quick.dll, qt5gui.dll, and qt5core.dll. Do I have to manually add them from somewhere?
The current directory structure is:
`test-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Release/release
|+qml
|+test
|-main.qml
|-main.obj
|-moc_qtquick2applicationviewer.cpp
|-moc_qtquick2applicationviewer.obj
|-qtquick2applicationviewer.obj
|-test.exe
|-test.exe.embed.manifest
Note: I pasted the qml directory as suggested in Nemanja Boric's answer from the parent directory, but that didn't solve the problem! :(
Also, I was under the impression that none of the source (apart from JavaScript maybe) wouldn't be openly distributed with the app, but compiled or packed inside the application somehow (note the .cpp file and the qml directory)?
Update 2
The application works just fine when run from inside Qt 5 Creator:
Starting [...]\test-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Release\release\test.exe...
QOpenGLShader::link: "(41,18): warning X3206: implicit truncation of vector type
"
[...]\test-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Release\release\test.exe exited with code 0
Well, apart from that one awkward warning...
You need to copy qml files into your current directory. When you create release application with QtCreator, you will have this directory structure (or something like this):
example-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Release
|- debug
|- qml
|- release // application executable is here
What you need to do is to copy qml folder to be in the same directory with your executable release file (simply copy qml folder into release folder).
About dll files - you can copy them manually from QtInstallDir/bin folder or you can add that directory into PATH, if you are developing on that machine - it could be easier.
You don't need to publish cpp files, but you need to publish qml files. What you can do, through I never succeed, but it seems to be possible is to bundle qml files into Resource file, and to load it from resources, but that can be extracted easily, too - so - don't put your logic or confidential informations in qml files.
Also, you need to copy all required dll files into directory with exe: qt5quick.dll, qt5gui.dll, qt5core.dll and libEGL.dll.

Qmake does not support build directories below the source directory

I have created an application that compiles and runs like a charm on OS-X. I would now like to start getting it to work on Windows. To start, I copied the project to a windows machine and just tried to compile, but got this error:
:: warning: Qmake does not support build directories below the source directory.
Any ideas?
Set the shadow build directory to some folder on the same level of your project directory:
folder/
project/
project-shadow-build-release/
project-shadow-build-debug/
You can do this in the "Projects" view, via the toolbar on the left. To me, this warning was just an annoyance, a project never failed to build because of it.
Don't copy your project.pro.user file when you are copying a project from one machine to another, or from one directory to another. When you open the project, Qt Creator will offer to create a new build directory in the proper place.
Andref gave the correct answer to resolve this warning, but you may want to understand why this requirement exists.
In fact, the build directory must be at the same folder level as the project (i.e. it can't be above or below). The reason why is that the linker is called from the build directory. Hence, any relative paths to library files will be different than what you entered in your project file.
It kinda sucks. I like to put all intermediate files in their own folder. But you simply can't with qmake.
.pro.user are generated files by Qt Creator. They are unrelated to qmake and should not be touched (and not put into a VCS for that matter)
Just remove the files with the pro.user extension , worked for me
I also got this, trying to compile a project created on linux.
Another way to solve it is to change the paths in the .pro.user file (in the directory of your project)
Right Click on a project: Set As Active Project
Click on the Projects button (The one with the spanner image)
Edit build configuration : Debug / Profile / Release / and change the default directories, OR just uncheck the Shadow build check box.
The Build directory path should now change to black, from red

Resources