LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Seeking advice for size optimiztion (https://www.linuxquestions.org/questions/programming-9/seeking-advice-for-size-optimiztion-241291/)

praj_linux 10-11-2004 08:08 AM

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.

itsme86 10-11-2004 08:35 AM

Make toolkit a shared library instead of a static one. When you compile/link the library use --shared and call it toolkit.so.

aluser 10-11-2004 11:12 AM

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 : )

Hko 10-11-2004 04:30 PM

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...

Hko 10-11-2004 04:32 PM

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

praj_linux 10-11-2004 11:02 PM

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.