• 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: Statically linking libraries
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Statically linking libraries


  • Subject: Re: Statically linking libraries
  • From: Michael Rawdon <email@hidden>
  • Date: Tue, 6 Dec 2005 14:24:50 -0800

On Dec 5, 2005, at 12:48 PM, Mark Lively wrote:
On 9/9/05, Eric Albert <email@hidden> wrote:
On Sep 9, 2005, at 10:29 AM, Mark Lively wrote:
There are a few libraries (libcurl for one) that I want to statically
link into my application.  Unfortunately xcode finds the dylib and
links that instead.  Well in addition but the links all point to the
dylib.

Anyway to force a library to link statically?

First, you have to have the static version of the library in a
different directory from the dynamic version.  Next, pass the
directory with the static library earlier to the linker than the
directory with the dynamic library.  Once you have that done, you can
pass the -search_paths_first flag to the linker.  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.

In Xcode, this would be "-Wl,-search_paths_first" under Other Linker
Flags.


Anyone have any ideas?

This worked great but I recently upgraded to Xcode 2.2 and I am now
getting "unrecognized option -search_paths_first" from gcc 4.0.1

Did you try:

-Wl,-search_paths_first

per Eric's recommendation above?

Xcode invokes the GCC driver to drive the linker, so if GCC doesn't support an option directly (which it doesn't seem to for -search_paths_first), then you need to "quote" it using GCC's -Wl, flag prefix, or the -Xlinker flag.  This should cause GCC to pass the flag down to the linker without trying to process it itself.  It looks like this might be your problem.

mhr



 _______________________________________________
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: 
 >Re: Statically linking libraries (From: Mark Lively <email@hidden>)

  • Prev by Date: Re: Omit the "Development" folder in xCode 2.2
  • Next by Date: [FAQ] Omit the "Development" folder in Xcode 2.2
  • Previous by thread: Re: Statically linking libraries
  • Next by thread: Mysterious error... to a newbie
  • Index(es):
    • Date
    • Thread