Can I deploy Qt as a "system library" on Windows? - c++

I am new to Qt, I installed Qt 5.6 and Microsoft compiler (I have Visual studio 2015 community).
It works.
I am focused on QML desktop applications on Windows 7/8/10.
I can't find informations about how to deploy Qt dlls once: if I make many applications that I deploy inside corporate LAN, I would like to install all the Qt dll required in one central location, so then I will speed up the edit/compile/test/deploy cycle.
I want to install every app in its respective folder, but the Qt "runtime" and dll only ONCE, not in EVERY app's folder.
That would be a huge time waste and space (and money).
How can I do? Is this possible?
thanks

Use cqtdeployer with deploySystem option.
This utility can deploy system libraries.
Warning, deploying system libraries may cause some qt modules to work incorrectly.
install catdeployer from online installer
open cmd
and call cqtdeployer with options:
cqtdeployer myApp.exe -qmlDir path/to/my/QML/folder -qmake path/to/my/qmake.exe -deploySystem
Where:
myApp.exe -you deployment application (release version)
-qmlDir path/to/my/QML/folder - this is path to your project qml folder
-qmake path/to/my/qmake.exe - the path to qmake that you were going with.
-deploySystem - option to capture system libraries.
If you wish, you can add the qif option to the end, this will force cqtdeployer to create an installer for your program.
cqtdeployer myApp.exe -qmlDir path/to/my/QML/folder -qmake path/to/my/qmake.exe -deploySystem qif

Related

Theme and Icons Problem with GTK3 Installed with vcpkg

I am using Visual Studio 2019 on Windows 10 and am trying to use GTK in C++ and installed it using vcpkg.
I've installed GTK using vcpkg according to the guide from GTK. I'm using Visual Studio 2019 and it is able to compile and run the example program here, but there is an issue regarding the theme and icons. According to the installation guide, under the section Building and distributing your application there are some things that must be done to get themes and icons to work.
I've started by downloading the Windows theme the guide suggests and have it in a share directory and then I've created a settings.ini file in an etc directory. It says to place this in the "install directory", which I assume is where Visual Studio is placing the exe for the program. I've tried it in both build and release, in the source files, in the top project directory - all with no success (and I did make sure it is targeting x64).
Just in case I also tried placing these where vcpkg is installed as well as where vcpkg installs gtk. No luck. When the program runs I get the warning
(gtkExample0.exe:16772): Gtk-WARNING **: Could not find the icon 'window-minimize-symbolic-ltr'. The 'hicolor' theme
was not found either, perhaps you need to install it.
You can get a copy from:
http://icon-theme.freedesktop.org/releases
So it seems that it is never finding the ssettings.ini file telling it to use the Windows 10 theme. Has anyone had any luck with getting this to work (both from VS2019 debugging runs and in deployment)?
To summarize the files:
share\themes\Windows10\gtk-3.0\gtk-3.20\ (downloaded from suggested GitHub repo)
etc\settings.ini contains:
[Settings]
gtk-theme-name=Windows10
gtk-font-name=Segoe UI 9
I've placed these in
<VS2019Project>\x64\Release,
<VS2019Project>\x64\Debug,
C:<path_to_vcpkg>\vcpkg\packages\gtk_x64-windows,
C:<path_to_vcpkg>\vcpkg\installed\x64-windows
All with no change when running from VS2019 under Release or Debug.
Theme and icons considered as external resources are not distributed by vcpkg, and the instructions given in the distribution guide from GTK regarding where these resources should be layout on windows 10 are not crystal clear. The problem has also been reported here vcpkg issue#4417.
The solution proposed hereunder is to install
all the resources in the <VS2019Project>\x64\Release directory of your VS project where your .exe application lives [This is a local solution the problem. A global approach should consider the setting of some user-defined free desktop environment variables which is not discussed here]. Icons can be picked from an ancillary MSYS2 distribution and the theme as indicated in the GTK Guide. The solution should be replicated for the Debug branch.
Supposing you have MSYS2, install mingw-w64-x86_64-adwaita-icon-theme package with the pacman package manager if not already done on your MSYS2 installation pacman -Syu mingw-w64-x86_64-adwaita-icon-theme.
Copy C:\msys64\mingw64\share\icons to <VS2019Project>\x64\Release\share\icons
you should get both hicolor and Adwaita icons as subdirectories of your target dir.
Copy the theme resources downloaded in the source gtk-3.20 directory directly into <VS2019Project>\x64\Release\share\themes\Windows10\gtk-3.0\. Do not locate these resources into a gtk-3.20 subfolder: to understand why consult this article Theme Location [assuming here that no global desktop environment variable has been set].
Create a <VS2019Project>\x64\Release\etc\gtk-3.0 directory, put your settings.ini into it.
Recompile and you should obtain a windows 10 look and feel for your application window.

What must be installed on client machine to run a QT Quick Application?

I am developing a desktop application using QT Quick. I have been searching and reading the QT documentation (http://doc.qt.io/qtinstallerframework/ifw-tutorial.html) for creating an installer and how to use windeployqt.exe and binarycreator.exe to deploy on a windows machine. So far so good , but since I want to target this application for windows XP as well.
I want to know exactly what is required to be installed on the target machine to be able to run my application when using MinGW orMSVC2015 during building, so that I may include them in my installer or make the end user download them. Just like we download .Net Framework , Visual C++ Redistributable or DirectX when installing an application.
We use windeployqt to gather all the Qt official dependencis. Two parameters of windeployqt are quite useful:
--debug or --release: determine whether your app is in debug state or release state. windeployqt will put corresponding version of DLLs to your exe's directory;
--qml and put the directory of your QML files after it. windeployqt will search your given directory and put all the QML modules to your exe's directory.
2018-11-05 10:52:34:
It seems the second parameter --qml has been changed to --qmldir.

How to make a standalone mac app using qtcreator

I have build an app using C++ and Qt on QtCreator. The result is a .app file.
Now, when I am running it from the Qt Creator it is running fine.
But when I am running it on a different machine (with no Qt installed) it is not running.
I have figured out the reason is because my .app file is not deployed properly (as there is no framework folder added in the .app)
But I am now having trouble solving it. I am following this link but not getting anywhere as it for console purely.
Is there a way I can fix it using Qt Creator?
A Qt application relies upon Qt's libraries, which must be shipped with the application, inside the built application bundle. The steps for deploying a Qt application for OS X are detailed in the documentation.
If you're not using any other libraries, besides those of Qt, you just need to run the tool macdeployqt, which is part of the Qt installation, in the bin directory. You can set this up to run as a build step in Qt Creator, but I suggest only doing it before you actually deploy the final bundle to another machine.
Calling macdeployqt will copy the necessary Qt frameworks into the bundle and setup the paths to the frameworks so that the binary in the bundle knows where to find them.
If you use any other frameworks or libraries, you need to copy those yourself and set the references to them using install_name_tool

Creating set up for Qt Project

I have Qt application on Lnux. I want to create a executable/set up for this so as to distribute it on Windows and there is no need to install Qt. I have created the executable for this by including all the dlls
but to run it user needs to go inside the folder.
I want such user do not need to go inside any folder,he can directly click the icon can run it. Or such tha user downloads the set up, and install it.
What can be done for this?
You can use the Qt Installer Framework which could be downloaded here. The Qt Installer Framework provides a set of tools to create installers for Linux, Microsoft Windows, and Mac OS X.
You can compile the Installer Framework on your own, but i think using a prebuilt one is more convenient. You can see the Qt Installer Framework Manual for a complete guide on how to make off-line and on-line installers. Creating installers is described here.
A tutorial for creating simple installers for small projects is available here.

Qt5 Application Does Not Run

I created an application using Qt 5 (compiled with Visual Studio '12). It works on my machine.
However, it doesn't work when I attempt to run it on another machine. The output I collected through cmd yielded an empty file.
The directory structure is as follows:
myapp.exe
icudt52.dll
icuin52.dll
icuuc52.dll
libEGL.dll
libGLESv2.dll
msvcp120.dll
msvcr120.dll
Qt5Core.dll
Qt5Gui.dll
platforms/qminimal.dll
platforms/qwindows.dll
The most relevant post I found was Application deployed with QT5 libraries does not start on Windows 7 - yet the solution (including qwindows.dll & qminimal.dll) didn't work.
Any ideas?
Windows will report a number of launch errors just when you double click on your exe outside Qt Creator. It looks like you have included most or all of these already.
Your development machine typically will not have problems launching and running its qt plugins because of the LibraryPaths that are searched by your exe. http://qt-project.org/doc/qt-5/qcoreapplication.html#libraryPaths
Dependency Walker will do the job and show you what you need to know, but the output is pretty complex and can be hard to decipher.
The easiest way I have found to figure out what Qt plugin dlls I am using at runtime on Windows is to do the following:
Exit Qt Creator.
Open the install folder for the compiler you are using with Qt in Explorer. For example:
C:/Qt/5.3/msvc2010_opengl/
Create a copy of the plugins folder in place (Copy of plugins folder in the same path as plugins, so its parent is msvc2010_opengl in this case).
In another explorer window, open your exe (Qt program) on your development machine. Run a minimal test of your program to make sure the major features are working. (Many runtime plugins don't get loaded until QObjects that use them are instantiated).
Delete the plugins folder in the Qt path.
Windows will lock up all the dlls that are in use by your exe and prevent you from deleting a number of dlls. Click skip for all the un-deletable folders and files.
Now go into each of the folders that you couldn't delete before and try to delete all the individual dll's in each folder. Click skip for all the un-deletable dlls.
Now when you are all done, you are left with a skeleton of a plugins folder, only showing dlls that your application is using.
It will probably include the folders: accessibility, platforms and imageformats and more depending on what you included in your .pro file.
Close your exe.
Copy the contents of your stripped down plugins folder to sit right next to your exe.
Restore your backup of the plugins folder (delete the stripped down plugins folder from your Qt path and restore the Copy of plugins).
Now you should be good to go. Test on a non-development machine.
A Note on VS C++ Runtimes
Also on some machines when deploying Qt with MSVC, the msvcrXXX.dll doesn't match what the rest of the system is using. Instead of deploying msvcrXXX.dll, instead in our installers at our office, we include the Microsoft C++ Redistributable Installer and run it in the install script. And on a few machines they had corrupted Redistributables, and we had to do a force install of redistributables to fix the `Referral from server' error we would sometimes get.
You can find the latest installer for MSVC Redistributables here Latest Supported Visual C++ Downloads.
Hope that helps.
You have to deploy your application before copying dll files manually.
To deploy your Qt application on Windows you can use windeployqt which can be found in:
< QTDIR >/bin/windeployqt
Example batch script may work on deploying your Qt Application (run with PowerShell or cmd):
C:\Qt\Qt5.x.x\5.x.x\MSVCx_x\bin\windeployqt <APP_PATH>/myapp.exe
After deploying your app, try to run your myapp.exe and note which dll files are missing.
Copy / paste required dll files from QTDIR/bin to your < APP_PATH >
for more information about deploying:
Windows Deploying Tool - windeployqt
Deploying on Windows