I am writing an algorithm using opencv library on an embedded processor (NIOS 2) , in order to port the library to be compiled on nios :
1 – I removed highgui and all functions that deals with IO operations .
2 – I took the remaining files (which are many) and added them to a new eclipse project along with my main.cpp.
3 – I can compile the code and run it fine but the main problem is that the output file which will be downloaded to the embedded processor (.elf file) is too large ~20 MBs with no optimization and ~6 MBs with optimization level 3.
Are there any tips to compile only the needed files in this large project and skip other files that I don’t call in my code ?
The linker already strips out things that simply can’t be called, assuming you are building a normal executable binary with a
main().If you know certain files aren’t used at all, then remove them from the project. Any errors that result should tell you how they actually could be called, and you need to remove the code paths that could lead there.
You might use
-Osto optimize for size rather than-O3, but I don’t know how much difference there is on the NIOS platform, where (unless things have changed radically) optimization for size is always essential.