Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
137 Views

how to reduce size of a linux so file

hi,
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.
thanks.
0 Kudos
4 Replies
Highlighted
Novice
137 Views

Quoting - uri1234
hi,
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.
thanks.

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.)
0 Kudos
Highlighted
Beginner
137 Views

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.

The options

-fno-inline

-fno-exceptions

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.

0 Kudos
Highlighted
Employee
137 Views

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?

0 Kudos
Highlighted
Employee
137 Views

Are you using -g? Sometimes that can be pretty hefty.

As always, an example is helpful to get a complete and knowledgeable answer.

Dale

0 Kudos