I use the CImg library to write plugins for an image-editing software I created.
The problem is that when I include CImg, size of the plugins explodes from 200kb up to 2Mb!
But in this particular case I only use 5% of CImg code!
So my question is: is there a way to remove unnecessary code at compile time, so the final executable is not bloated?
(I use Qt 4.8.0 and the latest CImg, Qt Creator and MacOS Lion).
Compile/Link flags:
QMAKE_CXXFLAGS += -Os -fdata-sections -ffunction-sections
LIBS += -Wl –gc-sections
Make sure you are compiling with full optimisations (or just
-Oswhich is size optimisation) and stripping debug symbols withstrip -s. That can take up a lot of space.Also it could be that while you are only using 5% of the CImg code, the 5% you use is using the other 95% internally. Pretty much the best you can do is optimise and strip debug symbols.