• 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
Re: Linking statically when a dylib exists
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Linking statically when a dylib exists


  • Subject: Re: Linking statically when a dylib exists
  • From: Eric Albert <email@hidden>
  • Date: Fri, 15 Jul 2005 08:53:47 -0700

On Jul 15, 2005, at 7:56 AM, Chris Espinosa wrote:

On Jul 15, 2005, at 3:21 AM, Jerry wrote:

I know this has been asked before, but not as far as I know since XCode 2 so maybe something has changed...

Is there any solution to the problem of XCode linking to foo.dylib if you add libfoo.a to your project? Removing the dylib is not a particularly good option as other applications on the system rely on it, and I'd like to avoid fragile solutions such as shell script build phases.

This is baked-in gcc behavior, and the only way I've found in Xcode to override it is to add the full path to the file, including extension, in a -l directive in Other Linker Flags (e.g. -l/usr/local/lib/foo.a)

Technically it's ld behavior rather than gcc. :) That said, if your .a is in a different directory from the .dylib, you can link against the .a by passing the -search_paths_first flag to ld and making sure that the directory containing the .a is passed to ld before the directory containing the .dylib. From the ld man page:


-search_paths_first
By default when the -dynamic flag is in effect, the -lx and
-weak-lx options first search for a file of the form
`libx.dylib' in each directory in the library search path, then
a file of the form `libx.a' is searched for in the library
search paths. This option changes it so that in each path
`libx.dylib' is searched for then `libx.a' before the next path
in the library search path is searched.


If they're in the same directory, ld will always link against the .dylib unless you pass an absolute path, as Chris suggested.

Hope this helps,
Eric

_______________________________________________
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


References: 
 >Linking statically when a dylib exists (From: Jerry <email@hidden>)
 >Re: Linking statically when a dylib exists (From: Chris Espinosa <email@hidden>)

  • Prev by Date: Re: error: array bound is not an integer constant
  • Next by Date: Re: Testing a framework using SenTestingKit and the debugger
  • Previous by thread: Re: Linking statically when a dylib exists
  • Next by thread: Re: Xcode 2.1 saving lag
  • Index(es):
    • Date
    • Thread