• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Static Linking, -syslibroot, and MACOSX_DEPLOYMENT_TARGET
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Static Linking, -syslibroot, and MACOSX_DEPLOYMENT_TARGET


  • Subject: Static Linking, -syslibroot, and MACOSX_DEPLOYMENT_TARGET
  • From: Patrick Rutkowski <email@hidden>
  • Date: Fri, 6 Aug 2010 22:08:46 -0400

I'm confused about the roles of both -syslibroot and MACOSX_DEPLOYMENT_TARGET in the process of linking static libraries on OS X.

Xcode, when building a static library, does something like this:
(Note that I've snipped away long paths just to make things easier to read)

===================================================================
setenv MACOSX_DEPLOYMENT_TARGET 10.5
libtool -static -arch_only x86_64 -syslibroot /Developer/SDKs/MacOSX10.5.sdk -filelist x86_64/foo.LinkFileList -o x86_64/libfoo.a

setenv MACOSX_DEPLOYMENT_TARGET 10.5
libtool -static -arch_only i386 -syslibroot /Developer/SDKs/MacOSX10.5.sdk -filelist i386/foo.LinkFileList -o i386/libfoo.a
===================================================================

And then Xcode finalizes by running:

===================================================================
libtool -static x86_64/libfoo.a i386/libfoo.a -o Release/libfoo.a
===================================================================

Note that in the first set of commands both -syslibroot and MACOSX_DEPLOYMENT_TARGET are present, while in the finalization command neither is present.

What I'm confused about is why these flags are needed _at all_ when building static libraries, even universal and backward compatible ones.

To illustrate my point, consider how you might build a universal backward compatible library from the command line, if for example you didn't feel like using xcode for whatever reason:

===================================================================
ar cru libfoo-x86_64.a *-x86_64.o
ar cru libfoo-i386.a *-i386.o
libtool -static -o libfoo.a libfoo-{x86_64,i386}.a
===================================================================

ar(1) just archives the arch specific .o's into an arch specific .a, twice. And then libtool builds a fat .a out of those two. No MACOSX_DEPLOYMENT_TARGET seems to be necessary here, and -syslibroot seems even more useless.

Or am I just too clueless about what these options actually do?

I've scoured apple's docs, but I can't find much on either linker option (at least not in relevance to this specific example).

Anyone have any ideas?

-Patrick

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Finding code exit points w/in gdb
  • Next by Date: XCode default path type
  • Previous by thread: Re: Finding code exit points w/in gdb
  • Next by thread: XCode default path type
  • Index(es):
    • Date
    • Thread