I'm using the apple gcc to compile a dylib that I'm going to redistribute. For various reasons I'm using some libraries, let's say libz
to keep it simple.
Since this library is not typically found on a Mac system I wish to static link in used symbols into the dylib by passing the path to the .a-file
to simplify deployment.
Now, the linker links in all symbols from the lib into the resulting dylib although I only reference a subset. On linux I've never encountered this problem, the linker happily discards all unreferenced symbols and creates a very slim executable, so it should be possible. The dylib file I have now is ~10 times larger than it should.
I've tried fiddle around with the -dead_code linker flag, but to no avail. Perhaps I just don't understand it?
Does anyone know the solution to this?
--gc-sections
switch. I tried the-gfull
switch together with the-dead_strip
but to no avail. – Subway