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.