QT Creator C++ and run time lib - c++

I'm planing for making setup file in qt creator for some proposes , any way my questions
Dose the release exe required any run-time lib ?
Regareds

If you dynamic link your app, it will need some libraries (if you are developing on Windows, use Dependency Walker to identify all of them).
Also, take a look at the Qt modules your app need to compile: each of them corresponds to a library, which you will need to bundle with your app.
If you are static linking, I believe you may need a smaller number of libraries (those that are not bundled with Qt), but will still need.
Hope it helps.

Related

Distributing Qt/C++ application cross-platform

I'm struggling to deploy my Qt/C++ application, probably because I have not found a good introduction about this online. In brief my question is how do I setup an installation framework which requires only minimal, or preferably no, compilation before shipping to users.
I want to deploy the GUI to users on different platforms, who may or may not have admin rights on their machines. I have found different options:
Statically compile Qt -> statically compile an executable -> distribute the executable. With this setup I have encountered a Windows security warning, which requires admin privileges (I have not yet tried on Linux / macOS). And frankly this approach seems sub-optimal, as my compiler has no idea about how to compile optimally for my users.
Create an installer. But there I start to be confused... Do I need to provide a statically compiled executable of my GUI, or just of the installer, or neither? Or can I avoid pre-compiling on my side all together by using an installer from Qt with built-in compiler/libraries?
With this setup I have encountered a Windows security warning
You didn't sign the binaries. This issue has nothing to do with Qt. You'd face it even when distributing a trivial "Hello World".
Ensure that you sign all of the following:
The executables.
All DLLs that you redistribute and are not signed (verify each one).
The installer.
my compiler has no idea about how to compile optimally for my users.
Since C++ doesn't use just-in-time compilation, this statement is a truism. When you dynamically link your compiler will also have "no idea" how to compile "optimally for your users" if you imply that you need CPU-specific variants of your code. This has to be addressed by having multiple executables, each compiled for a particular CPU, and selecting them on installation. I don't think you meant that, though. But then I have no idea what you mean by "compile optimally for my users".
Do I need to provide a statically compiled executable of my GUI
It's up to you. If you don't provide a statically compiled executable, you will need to provide all of the dependencies: the C++ runtime of your compiler, and all the libraries and plugins needed by Qt.
The procedure for producing a statically linked executable on Windows, Linux and OS X is identical. You start with a statically configured copy of Qt (configure -static -static-runtime), then build it, and then use that to build your application. The end product will be statically linked against C++ runtime and Qt libraries.
Do I need to provide a statically compiled executable of [...] the installer
Only if you compile the installer program yourself using a C++ compiler. Most installer generator packages take care of creating an installer that has no additional dependencies, i.e. you can run it on a bare Windows system.
can I avoid pre-compiling on my side all together by using an installer from Qt
Qt provides no pre-built installers for re-use.
You can use e.g. NSIS to deploy the compiler runtime, Qt libraries and plugins, and your application and any data files it needs.
Or you can statically compile your application so that it has no dependencies and is a single .exe file, and have it as a portable application. It could also self-install, i.e. you could bundle the installer within the application, and on startup the application could detect whether it's already installed, and if not it'd relaunch itself in administrative mode and perform the installation.
Obviously you need to build your application on each platform you want to distribute it to. Easiest way is to link all the QT libraries dynamically to your application. After that all you need to do is provide your application (as in exe file on windows, or executable on linux etc) and the QT libraries you used (DLLs on windows, SO file I think on linux etc)
For example (on windows) if your app is called MyApp and uses QTGui, QTWidgets and QTNetwork, then you have the following files to distribute:
MyApp.exe
QTCore.dll and few other DLLs needed called icu*.dll something, can't remember)
QTGui.dll
QTWidgets.dll
QTNetwork.dll
and you can zip them all in one zip, create an installer etc.
EDIT Few notes after the follow up in the comment.
The standard library (what you called default library that has vector class) is part of the c/c++ runtime (on windows) or installed on linux systems etc, so no, you don't have to worry about this. I can't say for all compilers but for some you can specify a flag/parameter to link this runtime statically (rarely there is a need to do this).
On windows there is a tool called dependency walker, which gives you the list of all DLLs needed for the application to run. On linux systems I don't know, never needed one really. But for your own application, you do know which libraries you need, since you wrote it :)

Distribution of C++ application with dependencies in Visual Studio

I'm a junior programmer. I have developed a Visual Studio C++ project with a fair amount of dependencies: Boost, a fingerprint recognition library and Windows Biometrics Frameworks. As for today I know the Windows Biometric Framework can be downloaded from the standard Windows Update and I am not concerned about that, to my knowledge, the application is ready to search and link WBF dependencies on the computer by itself.
My concern is: which is the easiest (not most efficient, I need speed here) way to pack the executable file with all the resources and dependencies this .exe needs (Boost and the fingerprint recognition SDK) so that I can minimize distribution troubles, i.e this dll is missing, please reinstall the application, and things like that, without having to compile everything in the client's computer?
I've been able to see a couple ways here: copy the dlls listed in the project config, change to static linking... but I don't know if that is the simplest way. I have little to no trust in my abilities for this and those methods seem quite manual, wondering if there might be an automatic way for doing these things?
I'm not familiar with the fingerprint library or WBF, but most of Boost resides in headers so its compiled in when you compile your application. Some, like the threading library and system specific calls(e.g. getting CPU core count) are libraries that are statically linked to.
What format of the fingerprint library is provided? Dynamically, there would be at least a .dll with a corresponding import .lib file. Your application links statically to the importer after compiling, and binds to the library during run time. Or the library can be included in one large, single .lib that's linked to your application after its compiled. If you have both options available and you only want to distribute the binary file, use static linking.
Like in any systems, you will need to include every .dll libraries your app links and every external resources(images, config files, ...) your app uses. I usually make my Windows distributions by using http://www.jrsoftware.org/isinfo.php.
Very easy to use.

First time Deploying Qt Application, dynamically link?

I'm starting to look into deploying a Qt application I've been developing but I've never had to deploy any C++ application before this.
I want to be able to ship my product as a pre-compiled executable that dynamically links against shared library files(Qt) for Linux/Windows so that there is an executable that looks in its own sub directories for libraries instead of libraries that may be installed as a result of other Qt products.
Is this something that is possible? Or must the Qt library files be installed separately for an application to link against them? I want to avoid requiring the end user to install ANYTHING on their systems while also avoiding static linking.
This is a normal behavior for Qt. How to do it greatly depends on your build system.
If you use CMake, you can generate installers with CPack. Here is a link to adding the required shared libraries to an installer. CPack makes many different types of installers for Linux, Windows, and Mac OS X.
You can also generate your own installers using NSIS. This is a lot more involved but doable.
Qt has documentation on how to deploy applications that use their libraries.
At my company, we do both CPack and NSIS. The CPack way is a lot easier and there is more examples online.

How can I strip down the Qt libraries to remove stuff not used by my application?

I'm shipping a stand-alone Linux application with Qt libraries compiled-in.
Is there a tool which would scan my source code, see which classes/methods my app uses, then it would pluck the unnecessary/unused stuff out of the Qt source code and compile Qt libraries tailor-made for my application without any extra bloat? This is the best case scenario, of course.
But what is the closest existing solution that would allow me to make my Linux stand-alone app with compiled-in qt libs as slim as possible?
Is there a tool which would scan my source code, see which classes/methods my app uses, then it would pluck the unnecessary/unused stuff out of the Qt source code and compile Qt libraries tailor-made for my application without any extra bloat?
The linker already does this for you. If you're statically linking to the Qt libraries, then only the code for the functions that you're calling will be embedded into the executable.
You don't need an external piece of software to do this. It doesn't matter how big the Qt libraries are on your development machine.
for additional size reduction of your program try UPX - it will make your application even smaller.
what is the closest existing solution […] to make my Linux stand-alone app with compiled-in Qt libs as slim as possible?
Specifically for Qt, since early 2019 there is the build process configuration option -ltcg to enable link-time code generation. According to the Qt company blog, it allows 15% size reduction for statically linked Qt and a smaller but still noticable effect for dynamically linked Qt libraries.

How to grab specifc libraries from my boost/lib folder?

I've compiled Boost and it works just fine. I would like to to copy specific .dll's and .libs into my project for deployment. The problem is I'm having a hard time finding which packages contain the libraries I need. I've looked around but haven't seen any documentation on what's actually inside the compiled libraries.
For instance, if I wanted to use boost:asio and boost::prt_vector in my project, which .dll/.libs should I copy over?
The entire library folder is over 1.2 GB so I'd rather not use the entire thing. I'm using Windows, vs2008.
Any ideas?
Are you deploying your application as an executable or as a project to be compiled by the user? If it is the former, you shouldn't need to send static libraries, as they're linked into your executable. If you build Boost libraries as dynamic libraries, you will need them of course.
But if you're deploying your app as something to be compiled, or if you have Boost DLLs, then as martiall said, you should use BCP.
You can use the bcp which is bundled in Boost
BCP Docs