[Solved] How to make static link app which compress qt resource data?
I would like to make a static application built with Qt on Windows platform.
Qt has built-in qCompress & qUncompress ability to make compress data.
I would like to put such data in Qt resource system & bundle with application.
Such compression doesn't need to open with other archive application, just use with my Qt application.
How can I achieve that?
This can't be done in a single step, as the resources have to be available at compile time.
I would go for a small helper tool which compresses a file using qCompress(). The so compressed file can then be added to the resource and loaded using qUncompress. This step be be easily automated using qmake and QMAKE_EXTRA_COMPILERS and/or PRE_TARGETDEPS.
Instead of the helper tool you might use gzip to compress the files. You then have to write your own zlib wrapper (qCompress() / qUncompress() is just a zlib wrapper) as gzip uses indeed the same compression algorithm, but a different format.
What do you want to archive with compressing the resource?
Once you access the data (and you will, or why did you add it in the first place?) you will have an uncompressed copy in memory... in addition to the original compressed data. So you have more data instead of less.
The only case in which I can imagine compressed resources to make sense is when you have many chunks of data with only a few used (== uncompressed) at any single time. I do not know whether the resource system makes much sense in such a use case. Maybe a way to not have the (compressed) data in memory would be better there.
@Tobias: while I understand your reasoning, that would also mean that we should not use .png in resources, but should use a raw image format instead that we can just map into a QImage, right?
Well, that's a legitimate question.
I think the reason behind compressing resources is a smaller binary and/or reduced startup times which might result in increased memory usage (depending on use case).
well, thanks for all advices.
Actually, I would like to make for embedding font in application.
Some text files to load from application to make single executable file ..