How can I strip down the Qt libraries to remove stuff not used by my application?
I'm shipping a stand-alon开发者_开发百科e 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.
精彩评论