Seeking advice for size optimiztion
Hi all,
I am having a library named toolkit.a. Its contains some exported functions. I am using only one function from that library, which must be very small in size. e.g. tk_strlen. Problem is that my execuable size increases a lot. Though I am using only one function from that library, I think my executable gets bundled with all the functions. How should I notiify the linker to ignore all the unused functions from the final build? Is it posiible? Praj. |
Make toolkit a shared library instead of a static one. When you compile/link the library use --shared and call it toolkit.so.
|
Of course, if your executable is likely to be the only one on the system which uses this shared library, the decreased size is an illusion : )
|
Did you write toolkit.c yourself?
If so (or even when not) you could try to just take out (copy) the code into your program (if the license allows, and you give credits where due). If you did not write toolkit.c yourself then realize that though you only use one function, that function may use a lot of other functions in the same library... |
As a side-note, just or fun, see this on how to write tiny programs for Linux:
http://www.ubergeek.org/~breadbox/so...tiny/home.html |
Back to square one,
This library is a part of our project, and writen by us. Problem was that our project contains a set of .so files. We separated a common set of function from all the libraries, and maintained it in toolkit.a. Our project specification does not want a introduction of new .so file. But using toolkit.a resulted in increased size of the libraries. There must be some way/option to avoid bundling of non used function in a final build. Praj. |
All times are GMT -5. The time now is 02:28 AM. |