H
H
horror_x2012-05-31 20:33:03
Programming
horror_x, 2012-05-31 20:33:03

How possible is it to remove unused code and data from static libraries?

There is a task: to quickly and easily create GUI applications as small as possible (ideally, so that the data and interface code take no more than 3-5 megabytes) in the form of a single executable file. Multiplatform is desirable.
Qt is ideal as a framework, but it is too cumbersome. Attempts to rebuild it with a minimum set of functional gains in size practically did not give. Alternatives like wxWidgets were also considered, they have no advantages compared to Qt. Any lightweight libraries are either too confused or have other critical flaws.
Actually, the question is: are there ways to link the application so that there is no unused code / data in it? There must have been something for this.
PS I know about executable packagers, the question is about removing redundant data.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
horror_x, 2012-05-31
@horror_x

For MSVC, MikhailEdoshin suggested the ideal solution :

It does not work by itself, but only if you tell the compiler to pack functions into the so-called. COMDAT objects ( /Gy ), and for the linker to delete such objects if they are not used and/or "collapse" identical objects ( /OPT:REF, /OPT:ICF ).

B
BrainHacker, 2012-05-31
@BrainHacker

Take the IDE, add the Qt framework project and your project there. Set up your project to reference Qt code. You build the Qt framework itself as a static library.
As a result, the compiler will take from Qt only those parts of the code that your application really needs.
All of the above works exactly for VS 2010.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question