user1797612 user1797612 - 2 months ago 6
C++ Question

Is it safe to strip a shared library after linking?

Let's suppose that I got

lib.so
, I compile the binary
mySoft
and I link this to
lib.so
.

At this point, considering that everything is working as expected, It's safe or not to take
lib.so
and strip it with
strip -s lib.so
?

To be clear I'm not interested on linking other binaries to my
lib.so
after
mySoft
is properly generated, I'm only interested on keep
mySoft
working and gain some disk space and maybe a small edge in terms of performances.

Answer

Yes, it's safe. strip only removes symbols that are not needed (because they have already been linked). Those symbols are useful for debugging, but they are never needed just for executing the code.