I am currently cross compiling OpenCV for a homemade architecture. Everything works perfectly expect that I want to optimize/reduce the memory .text section of the elf file. I am only cross-compiling the core, flann, zlib and imgproc module of opencv. Everything is done statically and I put all the compile flags for opencv cross-comp with -ffunction-sections -fdata-sections -fno-common and then I link with -Wl,--gc-sections for my binary.
I am only using the cv::Mat object and functions such as threshold, sobel and more complex one but when I nm (see man nm) I have a whole bunch of objects and functions that I never use and therefore my binary size explode. (I checked the opencv code and they are not used)
I suspect that the RTTI (Run Time Type Information) of C++ is the cause. Actually the compiler can't remove unused objects and functions because it is solved at run time ... That is why my compiler brings everything.
Is there any tricks that could help me without too much modifying the opencv source code in order to reduce my binary size ?