Qt Build w/ DLLs Included - qt

In Qt when I build a project it creates the executable but it doesn't include the necessary DLLs. Is their some option I can turn on to do this for me?

I'll assume you are referring to deploying your application. If you build with static linking to Qt, you won't have to distribute Qt DLLs but you will have a large executable. You may have to compile the Qt library yourself to get static libraries.
Dynamic linking will require you to copy the appropriate Qt DLLs with your application. Some build environments may have an option to help with this. If you mention what your development tool chain and platform is in the question, somebody may be able to help with specifics.
Qt has some documentation related to deployment here.

Related

In a cross-platform .NET Core executable, how can I specify paths to native dependencies / where do I put them?

I've been using p/invoke to call some native dependencies in a cross-platform web app on .NET Core. This only works because I've specifically installed and ldconfiged those dependencies.
Ideally I'd like to be able to run dotnet publish --self-contained against the appropriate platform and have that command include all the so files it needs, whereever they need to be, without ldconfig. I don't know if this is possible.
So my questions are:
Where does .NET core look for native dependencies if you do not use ldconfig? Does it matter if its a web app?
If the answer to (1) is not "nowhere," how can I include these dependencies when I do dotnet publish?
The self-contained option is meant to create a portable publish option. The output folder would contain all required native and any set up required to run in the specified platform without the need of installations. All dll dependencies must be in the bin folder.

In a Visual Studio 2012 project, how can I avoid copying and pasting QT DLLs into executable directory?

I'm using Visual Studio 2012 to build a QT 5.5 application.
Note, I use CMake to generate the Visual Studio project and solution files.
If I build the Release solution, when I run the .exe I get an error complaining the dll's were not found. I can fix this error, by copying and pasting the required dll's into the project's Release directory.
How can I avoid copying and pasting the required DLLs?
Do I need to specify the DLLs and/or their path in Visual Studio?
Is there a way to use CMake to specify the DLLs and/or their path?
For providing the Qt DLL's along with your application, the windeployqt tool which comes with Qt itself is probably what you want. It knows about Qt's plugins, etc. and can copy in the relevant Qt DLL's and plugins for you. Depending on what you are trying to do, you may want to invoke it as either a post-build step, as an install step or both. There's also a macdeployqt tool for Mac OS X, but there is currently no equivalent linuxdeployqt tool.
For taking care of copying in any non-Qt DLL's, CMake's BundleUtilities module can be used to automatically copy in any DLL's that the executables/libraries depend on. Unlike the Qt-specific deploy tool, BundleUtilities works for all platforms, but it doesn't know anything about Qt plugins which would be loaded dynamically at run-time. Again, use the relevant function(s) from BundleUtilities as a post-build and/or install step. For Qt4, the DeployQt4 module invokes BundleUtilities internally, but CMake doesn't provide an equivalent module for Qt5, instead choosing to let Qt itself provide the necessary support.

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

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.

Qt cross-platform development?

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).

Resources