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: Building static



On Saturday, December 7, 2002, at 09:25 AM, Jerry Pendergraft wrote:

On Fri, 6 Dec 2002, Kevin Van Vechten wrote:

On Friday, December 6, 2002, at 05:58 PM, Justin C. Walker wrote:

I want to build an app that is dependent only on the dylibs that "come
with" Mac OS X, so Joe Random can just download this thing and run it
on his system without having to worry about finding/building the other
libraries that it (the app) uses.

A noble pursuit. =)

I have this building fine, but for one library. That library (gmp)
comes in both .dylib and .a forms. How can I force it to use the .a
version? As it stands, the app seems to have a predilection for the
.dylib. Just to make life more interesting, one of the other (static)
libraries depends on gmp. Does this mean I have to rebuild that
library first, in some different way than I've done so far?

I assume you're linking with the -lgmp flag. I'm not sure how to force
-l to use the static library, however, specifying an absolute path to
the static library works. So try /path/to/libgmp.a instead of -lgmp.
I doubt you'll need to rebuild the first library.
Unfortunately specifying the full path links the library as an object
which will no doubt make your binary [much] larger than it needs to be.
There are two ways to ensure -lgmp uses the .a library
1) remove the .dylib form. Then the link must use the .a as found
2) specify -static -lgmp

Just to wrap this thread up: I tried #2, g++ -o ..... -static -lgmp
and the compiler (linker, actually) groused:

ld: torsion.o incompatible, file contains unsupported type of section 6 (__DATA,__mod_init_func) in load command 0 (must specify "-dynamic" to be used)

which I take to mean that '-static' affects more than just linking with 'gmp'.

Regards,

Justin

--
Justin C. Walker, Curmudgeon-At-Large *
Institute for General Semantics | Men are from Earth.
| Women are from Earth.
| Deal with it.
*--------------------------------------*-------------------------------*
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.



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.