Statically linked binaries on Mac OS X
I'm trying to link my binary statically, but it's failing to link because it can't find
A: Before discussing this issue, it's important to be clear about terminology:
A static library is a library of code that can be linked into a binary that will, eventually, be dynamically linked to the system libraries and frameworks.
A statically linked binary is one that does not import system libraries and frameworks dynamically, but instead makes direct system calls into the kernel.
Apple fully supports static libraries; if you want to create one, just start with the appropriate Xcode project or target template.
Apple does not support statically linked binaries on Mac OS X. A statically linked binary assumes binary compatibility at the kernel system call interface, and we do not make any guarantees on that front. Rather, we strive to ensure binary compatibility in each dynamically linked system library and framework.
If your project absolutely must create a statically linked binary, you can get the
Csu (C startup) module from Darwin and try building
crt0.o for yourself. Obviously, we won't support such an endeavor.
Document Revision History
Rewritten to clarify Apple's position on statically linked binaries.
New document that explains that statically linked binaries are not supported on Mac OS X.