PDA

View Full Version : New to QT, How do I remove dependencies to QT .dll files?



Fazor
29th March 2014, 12:10
Hello qt community!

I've been programming for a while in C++, and I finally discovered this awesome thing called QT. It's very beautiful, easy, and fun to use. I've been programming in Visual Studio ever since I began, but for many reasons I wanted to remove .NET from my gui applications, so I downloaded the QT creator.

I have one small issue, when I try to run built .exe files from QT, I get a bunch of errors saying that .dll files such as "Qt5Widgets.dll" being required in the same folder to run the application. I'm assuming these files are from some sort of SDK? However, I do not want to jam all of those files into the same folder as the .exe I am creating, is there any way to statically link those into the build so I can just run the .exe by itself? I've done some google searching, but again I am new to QT so I don't fully understand the whole linking process yet. If anyone could give me an in-depth answer on how I can achieve this, I will be forever grateful.

Thanks!

adutzu89
29th March 2014, 12:44
Here is the best explanation for deploying applications-> https://qt-project.org/doc/qt-5.0/qtdoc/deployment.html
The .dll files are libraries which can be found in Qt's installation folder.

Static linking is where you merge all your needed libraries inside the executable file making it bigger in size.
Shared libraries is where you deploy the needed libraries with your executable file.

Both have ups and downs which are explained in the link above, the main issue with static linking is that the executable file will be bigger, depending on your application, but you won't have issues of library files wouldn't be compatible if you release a newer version for the application.

With shared libraries you get a smaller executable and on "update" you will deploy only the executable and newer/modified files,but if a newer version was made using different Qt version then the original application you would need also to redeploy the libraries,depending on the difference between Qt versions used. This is also explained in the link above if you look into the links in the deployment page.

I suggest you do some documentation on deployment to see which is more suitable for you and look in both cases static and deploying with shared libraries.

Fazor
29th March 2014, 13:00
Here is the best explanation for deploying applications-> https://qt-project.org/doc/qt-5.0/qtdoc/deployment.html
The .dll files are libraries which can be found in Qt's installation folder.

Static linking is where you merge all your needed libraries inside the executable file making it bigger in size.
Shared libraries is where you deploy the needed libraries with your executable file.

Both have ups and downs which are explained in the link above, the main issue with static linking is that the executable file will be bigger, depending on your application, but you won't have issues of library files wouldn't be compatible if you release a newer version for the application.

With shared libraries you get a smaller executable and on "update" you will deploy only the executable and newer/modified files,but if a newer version was made using different Qt version then the original application you would need also to redeploy the libraries,depending on the difference between Qt versions used. This is also explained in the link above if you look into the links in the deployment page.

I suggest you do some documentation on deployment to see which is more suitable for you and look in both cases static and deploying with shared libraries.


Static linking says "i.e a new version of the application" that's literally what an update on a single .exe is when there's no external dependencies.

Also, this doesn't really explain how to achieve this. It only explains what it does.. I already know what it does, I just don't know how to statically link the libraries in qt creator.

adutzu89
29th March 2014, 13:23
Qt static linking and deployment-question on stackoverflow (http://stackoverflow.com/questions/1011197/qt-static-linking-and-deployment)
There are answers on that question which might help you get started.

ChrisW67
29th March 2014, 20:43
The DLLs "from some SDK" are the Qt libraries. Deploying these is no different to asking the end user to install yet another version of the .Net runtime in order for your latest Microsoft creation to run. The only difference being the user might already have a suitable .Net runtime install by default or from another application.

If you hold a commercial licence or are releasing your source under the GPL then you might find static linking useful. It comes with a range of limitations regarding dynamically loaded plugins that you may need to be aware of. Regardless of Qt licence some elements of Qt are only available under the LGPL, which imposes some other restrictions.
You start by building your own Qt libraries from source for static linking as described in broad terms in the deployment information linked above and the Windows-specific page.