Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 993
abirvalg Avatar asked Jan 20 '23 03:01

abirvalg


2 Answers

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.

like image 58
Cody Gray Avatar answered Jan 29 '23 22:01

Cody Gray


for additional size reduction of your program try UPX - it will make your application even smaller.

like image 32
Raiv Avatar answered Jan 29 '23 21:01

Raiv