Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: statically linking



> What is the proceedure for trying to statically link binaries?
> Normally, one would just pass -static to cc, and poof, out
> pops a statically linked binary.
> However, when doing this, I get:
> /usr/bin/ld: foo.o incompatible, file contains unsupported type of section 3
> (__TEXT,__picsymbol_stub) in load command 0 (must specify "-dynamic" to be
> used)
>

>cc -c foo.o foo.c
>cc -static -o foo foo.o
>Is there something I'm missing?

Yeah, you should have said:
cc -c -static -o foo.o foo.c
cc -static -o foo foo.o
if you do a cc -s -static foo.c and a cc -s foo.c you can see that there is a lot of extra information in the dynamic version.

But that just gives:
/usr/bin/ld: can't locate file for: -lcrt0.o

I don't think you can build statically linked binaries on Darwin, because there are no static libraries to link with. You have to build those first.

Regards,
John Hornkvist


--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.