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

Alexandre Gauthier supernaut at underwares.org
Mon Sep 11 07:37:52 PDT 2006


Hi,

I'm currently trying to learn C. I'm actually more of a network guy, but I
am motivated enough :P

So, here I am, trying to compile a static binary on OS X 10.4 Tiger, x86
(MacBook pro).

So I just invoke gcc with the -static option.

  $ gcc -static -o program program.c

The program seems to compile fine, but then, linking fails.

  /usr/bin/ld: can't locate file for: -lcrt0.o
  collect2: ld returned 1 exit status

I gather that somehow, this is due to the parts of stdio in libc it tries to
link in statically. Well, that fails. And crt0.o can't be found anywhere on
disk.

Is it just broken? Or am I doing something utterly wrong? Or maybe missing
something? I tried running gcc with -print-file-name=crt0.o

Any ideas would be appreciated :)

Thanks.




More information about the X-Unix mailing list