[X-Unix] Compiling static binaries with GCC fails?

Alexandre Gauthier supernaut at underwares.org
Mon Sep 11 07:43:22 PDT 2006


Erm, bad practice to reply to myself, but I just figured something out:

On 11/09/06 10:37, "Alexandre Gauthier" <supernaut at underwares.org> wrote:
> 
> So I just invoke gcc with the -static option.
> 
>   $ gcc -static -o program program.c
> 
--snip--

I browsed the gcc manpage and came across this:

  -static
    On systems that support dynamic linking, this prevents linking
    with the shared libraries.  On other systems, this option has no effect.

    This option will not work on Mac OS X unless all libraries (including
    libgcc.a) have also been compiled with -static.  Since neither a static
    version of libSystem.dylib nor crt0.o are provided, this option is not
    useful to most people.

Well this sort of sucks. It explains why the linker can't get its greasy
hands on crt0.o...

Is there any way to get a static binary *at all* under OS X?




More information about the X-Unix mailing list