Qt cross-platform development? - qt

I just have a little question about running Qt created apps on different operating systems.
As a normal user do i have to install Qt framework to run Qt apps ?
I mean i've created Qt app using Windows , then i made a build for Linux .
Do i need to install the Qt framework on the Linux pc inorder to run that app ?
Or there is a way to package all the needed libraries into the app installer .
Best Regards

You can deliver the dynamic libs you need with your application, as it's described here:
http://doc.qt.io/qt-5/deployment.html
Since Qt is not a system library, it has to be redistributed along
with your application; the minimum is to redistribute the run-time of
the libraries used by the application. Using static linking, however,
the Qt run-time is compiled into the executable.

Depends what you mean by 'framework', you will need the runtime libraries, unless you paid Nokia for a license to allow static linking.

For Linux, I think you would generally ensure that the Qt packages have been installed during installation (i.e. make them a requirement of the package you provide). Under Mac OS you would need to package the .so (shared objects) with your application. Under Windows you do the same (provide the .dlls) and install them with the application (not in the system folders).
The issue with static linking that #cbamber85 is alluding to, is the conformance with the LGPL licence where it's legal to link to the libraries at runtime but not at compile time (i.e. use the .so/.dll but not the .a files).

Related

An installer for Qt apps

I've created a Qt calculator app using Qt Creator 3.6.0 purely in C++ code (I didn't use Designer)
I would like to know how to use Qt to make it installable for publishing.
I ran the app in both Release and Debug modes and have both folders of the two.
I also downloaded and installed Qt Installer Framework Opensource 2.0.1 for my Qt Creator 3.6.0 (the IDE I use for Qt).
And I also have the .dll files needed to run the .exe file.
I've searched the Web for it. But since I'm a novice in Qt I can't do the works properly, or I don't understand. (They seem complicated)
Now, is there any straight forward method to use an installer for the app to make as platform independent as possible?
If so, what installer? And how to do the process? This is the first time for me.

Deploy qt application with all its dependencies

I developed a QT application on ubunty linux. I want to include dependencies in my deployed file so that my application can works in any other machine running with ubuntu.
The best way to achieve this is to distribute your application as a .dpkg so the dependencies can be automatically installed. Including dependencies in the binary is tricky and generally means statically compiling libraries instead of dynamically linking them but even then you run into problems.

How to package qt application?

I have made a qt application.
What is the easiest way to give it to someone else ? If I just give the executable, it doesn't bundle the required dependencies (for example, I get: error while loading shared libraries: libQt5XmlPatterns.so.5: cannot open shared object file: No such file or directory).
Is there an easy tool to bundle the required libraries, or to make use of the package management system (that is to say, a tool that would automatically make a .deb out of the executable) ?
You may create a static build and embed Qt libraries for your specific platform.
Build Standalone Qt Application for Windows
Deploying Qt Applications Linux

Deploying Qt with MinGW requires VC++ redistributable?

I'm testing an application using Qt 4.7.3 compiled with MinGW on a clean XP virtual box. The application wasn't working and after much grief, I traced the error to needing to download the Visual C++ 2005 redistributable. I downloaded this and it worked. Something doesn't seem right here, shouldn't I not need any VC++ libraries since I'm using MinGW? Could it be a problem with my compilation? I should mention that I'm not using qmake to build.
The dependency on MSVCRT.DLL is due to MinGW itself. To quote mingw.org..
MinGW provides a complete Open Source programming tool set which is
suitable for the development of native MS-Windows applications, and
which do not depend on any 3rd-party C-Runtime DLLs. (It does depend
on a number of DLLs provided by Microsoft themselves, as components of
the operating system; most notable among these is MSVCRT.DLL, the
Microsoft C runtime library.
Also see: Should I redistribute msvcrt.dll with my application?
As noted in the Qt documentation, yes, that is required:
http://doc.qt.io/qt-5/windows-deployment.html

Qt and Qt application prerequisites

I am new to Qt, and I am working in Windows 7.
When I try to run my application directly, I see an error about missing some DLLs. I tried to fix them, but I could not (I tried to build statically).
Is there any correct solution?
My question is:
If I want to run my Qt application on other computers, what do I need? For example, for a .NET application we need to install the .NET framework on the target computer, but what about for Qt?
I searched for its SDK and found a SDK that was about 1.6 GB! Does this mean every time I want to install my application I should install a 1.6 GB sized SDK? That's far too bad.
Thanks.
You have to distribute your application with needed libraries.
If your application is running on Windows you can follow this guide: Deploying an Application on Windows. You can find needed libraries as dll in bin directory inside SDK. A basic Qt gui application needs at least QTCORE4.DLL, QTGUI4.DLL and, if you are using Qt Creator, MINGWM10.DLL. You can leave these libraries in the same directory as you application.
You can't link statically against Qt unless you have built the libraries in that configuration (which you won't if you've just downloaded the pre-built SDK). Be aware that if you do want to link statically there are licensing implications for some components.
If you have built a release configuration then you will need at least the libraries Alessandro mentioned, QtCore4.dll and QtGui4.dll. Depending on the other parts of the library you're using you may also need QtXml4.dll QtWebkit4.dll, QtXmlPatterns4.dll and possibly Phonon.dll. Check that you are building a release configuration rather than a debug configuration, as this won't run as it needs the Visual Studio debug runtimes, which you can't redistribute. If you are in doubt which dlls you need then use DependencyWalker to find out (note that this doesn't show Phonon.dll as it is loaded later).
Generally you'll only need about 4-6 of the dlls, you won't need the whole SDK.
Please consider that many applications use Qt, you have some real chance the DLLs are already installed. Anyway, beware of MSVC dependencies: we had some real nightmare deploying applications on some server, partly related to a policy switch from VS2005 to VS2008. Alessandro already given a good resource: see also this previous post.
If you're working with Qt5, besides the .dlls mentioned by the first answer, you must also add the platforms/ folder from the bin directory inside the SDK.

Resources