Qt Creator: creating a installer encapsulating 3rd party libraries - c++

I'm trying to build an installer for a Qt-based application. It depends on some Qt libraries, which is not a problem to build an installer, but it also depends on 3rd party libraries: OpenCV, SuiteSparse, FFTW, and some other libraries coded by me.
Is it possible to create a "one-click" installer with Qt Creator that handles both Qt libraries and these too? Or should I create a script that installs the dependencies and integrate it somehow in the Qt Creator? If so, how can I do that?
I'd like to pass most of the responsibility to Qt because this application should be installable in both OSX (in which I'm developing) and Windows, and I wanted to avoid maintaining two codebases if possible.

Related

When using Qt Creator with CMake, why do I not have to manually link the MSVC libraries?

Whenever I want to use 3rd party library code in my Qt creator CMake project, I have to link the library to my executable in my CMakeLists.txt so that the code can be used.
However, if I want to use code from e.g, MSVC 2010, or the Windows 10 software development kit, all I have to do is download and install it, and if then the code is ready to use.
Why is this?
Thanks.
The default behavior while searching dependencies in Windows is to look in all the system locations first, then the current directory, and finally any user-defined paths. That is why you don't have to explicitly link the Windows 10 SDK libraries.

How to build custom widgets for qt designer

I've read through the tutorials of Qt, I've searched the net, but I can't find the exact way on how to build custom witgets with Qt 5.8.x. In example with this tutorial one is able to build widgets for Qt 4.x as I already succeeded. For Qt 5.8.x I'am lacking in such straightforward tutorials.
Even if you use the build in wizard of Qt for setting up such custom widgets projects, one will end up with none recognized widget libraries.
So first of all, there is a confusion with the installing path, that the makefile should mention while installing the plugin.
In the project file one can find the section
target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS += target
After a straightforward installation of the open source mingw version of Qt 5.8.0 on a windows 7 machine in the path C:\Qt\Qt5.8.0, the variable "QT_INSTALL_PLUGINS" will extend to
C:\Qt\Qt5.8.0\5.8\mingw53_32\plugins
thus the "target.path" for the
make install
will be read as
C:\Qt\Qt5.8.0\5.8\mingw53_32\plugins\designer
But on the plain installation of Qt 5.8.0 with mingw the designer searches its plugins in
C:\Qt\Qt5.8.0\Tools\QtCreator\bin\plugins\designer\
As someone already suggested to me, one has to set the environment variable "QT_PLUGIN_PATH", where Qt Creator as well as Qt Designer ( in the subdirector "designer") searches its plugins in. So in order that Qt Creator still works properly one has to set the environment variable "QT_PLUGIN_PATH" to
the original path as well as to
the install path reffered to by $$[QT_INSTALL_PLUGINS]
So on my Windows 7 environment I set the variable "QT_PLUGIN_PATH" to
C:\Qt\Qt5.8.0\Tools\QtCreator\bin\plugins;C:\Qt\Qt5.8.0\5.8\mingw53_32\plugins
Afterwards Qt Designer is able to find the custom build widget library. But Qt Designer it not able to load the library. One interesting thing is that the designer also refuses the libraries provided by the installation of Qt itself.
on loading the custom widget lib it says:
"... .dll can't be loaded: the given procedure was not found"
on loading the libs supplied by the Qt distribution itselfs in the path C:\Qt\Qt5.8.0\5.8\mingw53_32\plugins\designer it says:
"... .dll cant be loaded: the mentioned modul was not found"
What I've done to build the library is, that I just ran through the project wizard to generate a custom widget for Qt Designer. With the so generated project I get the result of a non loadable lib, as mentioned above.
What do I have to change in the source/project files in order that the Qt Designer ist able to load the lib properly?
Thanks for any hints or suggestions!
You seem to use the MinGW compiler.
You cannot make plugins with that compiler with the default supplied Creator as it's compiled with Visual Studio 2013/2015 (depending on the Qt version).
Due to how DLLs works on Windows, you must use the same compiler that Creator is compiled with to build the plugin (otherwise it can't load it).
Go to "About Qt Creator" in the Help menu to check.
Also make sure to build the plugin in Release mode.

How to use static build of Qt to create a statically-linked release for Windows?

How am I supposed to use my static build of Qt in my project directory? There seems to be a missing step in the official documentation between building a static version of Qt and then building a statically-linked version of your app with that static version of Qt.
There's no explicit step, since all you need to do is use that statically-compiled Qt to build your project. That's all. From the command line, simply invoke the statically-compiled Qt's qmake and your project will statically link to Qt. From Qt Creator, add the statically-compiled Qt's kit to your project's configurations and build for it.
Of course you must first add that Qt version to Qt Creator, and add it to a new kit. Note that as far as both Qt and Qt Creator is concerned, a "Qt version" is a synonym for a build of Qt. So if you have 4 different builds of Qt 5.3.1 (say dynamic multithreaded, dynamic single threaded, static multithreaded, and static), they are considered different Qt versions. Because a "Qt version", as used throughout, has nothing whatsoever to do with the sources of Qt, just with a build of Qt. If all you do is download a source package of Qt, you have no Qt versions yet :)

How to build Qt5 app with their static libs?

I'm a Qt beginner and I want to know how to build Qt5 apps with their static libraries. Is that possible to build with static libs everything that can be build with dll's ?. I want to know because I don't want to install Qt libs everywhere where I want my apps to be running. For example I want to build with static libs app which code is in this post:
Widgets must be created in the GUI thread Error !. How to correct the code?
Is that possible ?
How to do that ?
In order to use Qt as a static library, you have to rebuild Qt itself.
You can find a guide here
It recommends rebuilding Qt as following:
cd C:\path\to\Qt
configure -static <any other options you need>
nmake sub-src
Make sure you've embedded all plugins you need. (see configure options)
However, not all Qt parts can be built as a static libraries. As far as I know, you may expose some difficulties with Webkit.
After rebuilding Qt, you can build your apps, as usual.
Note also, that Qt is licensed under LGPL or GPL or commercial licence. Using static version of Qt can impose some limitations on your app distributions.

To add or not to add Qt Libs and Headers to the Project Directory

Does it make sense to add relevant Qt Libs and headers (opensource version) to a projects repository or should I just reference them from the sdk directory ?
I (alone) am developing a cross-platform (windows/linux) c++ application which, will be using a number of thirdparty opensource libraries including Qt, OpenCV, log4cpp to name a few.
I started off development in Qt Creator for convenience (speedy GUI creation). Currently I have the Qt Sdk installed on both Linux and Windows outside the project directory.
I'm planning to move to CMAKE to for better configurability, e.g out-of-source builds and independance from Qt Creator and I would like to have all dependencies included in the project directory structure -so that I or anyone else can checkout the project and build without needing to install any other dependancies.
I have added all libs but Qt's to the directory as I am a little unsure weather its worth it -it seems like CMAKE depends on the Qt Sdk for compiling Qt specific files i.e moc, ui etc... (see here) is this the case ? or is there a better suited build tool ? (Originally I was I going to use Scons but I decided not to as the there seemed to be limited support.. and there hasn't been developement on Qt4 Tools since 2010, which doesnt inspire confidence either.)
Qt is too big to be put in a project directory, even if you include only one of its modules. Also you have some convenient functions in CMake to use Qt (add moc, rcc, ui). You can even write these functions by yourself (in fast, they just add a pre-build command).
For the build operations: you will need to use the moc (and maybe ui, rcc, ...), which is not provided by CMake. So, a person wanting to build your application must have the Qt SDK installed. Luckily, this installation is very easy.