Size of Qt release of simple console app
-
IHi, I'm new to Qt (about 2 weeks) and reentering the world of C++ after an absence of around 30 years. In this time I've been using various invocations of MS Visual Studio and Visual Basic. However, I now want to do some cross platform desktop development and Qt looks like an option after Microsoft pulled Visual Studio for Mac. So I've been playing qwith Qt 6.6.1., designing GUI elements etc., and decided to try a release of a simple console application testing the passing of function pointers (from https://www.geeksforgeeks.org/passing-a-function-as-a-parameter-in-cpp/). This is it:
#include <QCoreApplication>
#include <iostream>
using namespace std;
// Function that add two numbers
int add(int x, int y) { return x + y; }
// Function that multiplies two
// numbers
int multiply(int x, int y) { return x * y; }
// Function that takes a pointer
// to a function
int invoke(int x, int y, int (*func)(int, int))
{
return func(x, y);
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
// Pass pointers to add & multiply
// function as required
cout << "Addition of 20 and 10 is ";
cout << invoke(20, 10, &add) << '\n';
cout << "Multiplication of 20"
<< " and 10 is ";
cout << invoke(20, 10, &multiply) << '\n';
return a.exec();
}
I produced two releases, one using Minimum Size Release build configuration, and the other using just Release. In both cases, after running windeployqt (or windeployqt6) the result was a 12.9 MB bundle containing a 50 kB exe. The folder comprises my bit DelegateTest (50 kB), libgcc_s_seh-1.dll (74kB), libstdc++-6.dll (1.9MB), libwinpthread-1.dll (52kB) and Qt6Core.dll (6.53 MB). This seems excessive but they all seem to be necessary (I took some away and had to put them back.) .The exe file appeared in a build folder build-DelegateTest-Desktop_Qt_6_6_1_MinGW_64_bit-MinSizeRel (or ...-Release) so I don't think there's debug infor there (?).
In contrast, I compiled the same code (without the Qxxx bits, obviously) using Microsoft's standard C++14 or C++20 compiler using a VS2022 C++ console app project and got a 19 kB stand alone exe. Both do the same thing (but as an added bonus, the VS exe runs on a Win 7 PC and the Qt one does not (wants some more dlls)). I read that I can produce a standalone exe using Qt but that I have to do a static rebuild of Qt itself. Moreover, this changes the licence conditions (as Qt components are combined with my code) and is unlikely to produce an exe file smaller that the 50 kB because it will have more stuff in it.
So, have I missed something in my Releases as above? Should they be smaller?
-
IHi, I'm new to Qt (about 2 weeks) and reentering the world of C++ after an absence of around 30 years. In this time I've been using various invocations of MS Visual Studio and Visual Basic. However, I now want to do some cross platform desktop development and Qt looks like an option after Microsoft pulled Visual Studio for Mac. So I've been playing qwith Qt 6.6.1., designing GUI elements etc., and decided to try a release of a simple console application testing the passing of function pointers (from https://www.geeksforgeeks.org/passing-a-function-as-a-parameter-in-cpp/). This is it:
#include <QCoreApplication>
#include <iostream>
using namespace std;
// Function that add two numbers
int add(int x, int y) { return x + y; }
// Function that multiplies two
// numbers
int multiply(int x, int y) { return x * y; }
// Function that takes a pointer
// to a function
int invoke(int x, int y, int (*func)(int, int))
{
return func(x, y);
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
// Pass pointers to add & multiply
// function as required
cout << "Addition of 20 and 10 is ";
cout << invoke(20, 10, &add) << '\n';
cout << "Multiplication of 20"
<< " and 10 is ";
cout << invoke(20, 10, &multiply) << '\n';
return a.exec();
}
I produced two releases, one using Minimum Size Release build configuration, and the other using just Release. In both cases, after running windeployqt (or windeployqt6) the result was a 12.9 MB bundle containing a 50 kB exe. The folder comprises my bit DelegateTest (50 kB), libgcc_s_seh-1.dll (74kB), libstdc++-6.dll (1.9MB), libwinpthread-1.dll (52kB) and Qt6Core.dll (6.53 MB). This seems excessive but they all seem to be necessary (I took some away and had to put them back.) .The exe file appeared in a build folder build-DelegateTest-Desktop_Qt_6_6_1_MinGW_64_bit-MinSizeRel (or ...-Release) so I don't think there's debug infor there (?).
In contrast, I compiled the same code (without the Qxxx bits, obviously) using Microsoft's standard C++14 or C++20 compiler using a VS2022 C++ console app project and got a 19 kB stand alone exe. Both do the same thing (but as an added bonus, the VS exe runs on a Win 7 PC and the Qt one does not (wants some more dlls)). I read that I can produce a standalone exe using Qt but that I have to do a static rebuild of Qt itself. Moreover, this changes the licence conditions (as Qt components are combined with my code) and is unlikely to produce an exe file smaller that the 50 kB because it will have more stuff in it.
So, have I missed something in my Releases as above? Should they be smaller?
@punchedCard said in Size of Qt release of simple console app:
So, have I missed something in my Releases as above? Should they be smaller?
No and no. If you want Qt stuff then you have to live with it (or compile static). Comparing to a simply c++ hello world is completely wrong here.
-
@punchedCard said in Size of Qt release of simple console app:
So, have I missed something in my Releases as above? Should they be smaller?
No and no. If you want Qt stuff then you have to live with it (or compile static). Comparing to a simply c++ hello world is completely wrong here.
@Christian-Ehrlicher Thanks for the quick reply!