i'm compiling c++ code using intel compiler (11) for linux.
i'm getting a very large *.so file.
how can i reduce the file size?
are there any tools i can use to try and understand why it is so big.
I don't know of an user-friendly, easy to use tools, but 'objdump' will do the job. Start with 'objdump -s'.
Debug information is often the culprit, as is accidentally statically-include libraries you mean to dynamically-link to. You can run 'ldd' on a .so file to make sure it's itself dynamically-linked to the libraries it uses. (And statically-linking to core libraries inside a shared object causes serious problems.)
It depends what is very large?
Do you compare it to .so compiled with some other compiler, like gcc?
Is it 20% bigger or two times bigger?
Can you share your compilation options with us, so we won't be guessing so much.
I am also trying to reduce my code size, and this is my experience:
With icc, -O1 generates both fastest and smallest object in my case (lots of integer math). Your results may differ, but it is worth a try.
will also make much smaller C++ object, if your code does not use exceptions, or if the performance won't suffer by omitting the inline optimization.
You should also strip your .so file, if size matters to you.
Intel compiler may be doing inlining. It would be nice if you can help if you can quantify the increase in code size. Could you help us with sample testcase to help us review the code?