I’m developing an android app that uses the OpenCV and Tesseract library. I only use certain functions of these libraries. But with the libraries included, the size of the app grows from 4 to 50mb.
I obviously need to trim down the libraries. How would I do this?
EDIT: To maintain user-friendliness I don’t want to use OpenCVManager. I don’t want to force the user to install another app.
EDIT2: I need to do the same thing for tesseract libraries. I guess this works in the same way?
I’m absolutely not sure of what i’m going to suggest, but i recently found the
-gc-sectionsoptions in the GCC documentation. Used at link time, it’s supposed to strip all unused code sections from the final executable/library. This could avoid having to trim OpenCV manually, which must be a long and rather unpleasant task given the complexity of this library.To use it, you apparently have to compile each dependency using
-ffunction-sections -fdata-sections -Os, then link the whole code with-Wl,--gc-sections. It may deserve a try!I found some details on this page.
Don’t hesitate to correct me if i’m wrong!