Re: static libraries
Re: static libraries
- Subject: Re: static libraries
- From: Andreas Grosam <email@hidden>
- Date: Sat, 22 Oct 2005 15:28:57 +0200
On 22.10.2005, at 04:42, Steve Checkoway wrote:
On Oct 21, 2005, at 7:01 PM, Andreas Grosam wrote:
Guess, we need to *explicitly* specify
-L<lib-path> -l<name>
tupels in the "Other Linker Flags" build settings in order to ensure
that a certain library will be selected.
(the -Wl, syntax is not necessary, though)
If you just pass -L/path/to -lfoo and expect it to give use
/path/to/libfoo.a and there is a dynamic library with the same name
elsewhere, it'll get picked up unless you instruct ld otherwise by
using -search_paths_first. Since gcc doesn't know about that, you have
to use -Wl, to pass it along.
You are right, i missed that.
But unfortunately this too does not *always* solve the problem in all
cases:
Assuming, dynamic linking is in effect (the default) and you specified
the lib via -lx
The algorithm is as follows:
if
a) -search_paths_first is NOT set,
for each path in LibrarySearchPaths
if exists libx.dylib
return libx.dylib
endfor
for each path in LibrarySearchPaths
if exists libx.a
return libx.a
endfor
b) -search_paths_first is ON
for each path in LibrarySearchPaths
if exists libx.dylib
return libx.dylib
else if exists libx.a
return libx.a
endfor
The order for library search path is:
first all paths specified with -L, then standard library dirs (/lib,
/usr/lib, /usr/local/lib/)
If -Z is specified, then ld will not search in standard paths.
The search order of paths specified with -L is not documented, though.
So, if ld searches in any path where ld can locate a dylib, it will
select this first - no matter what you have dragged in into your
project. Xcode just takes the canonical name and passes it to ld
(through gcc).
In order to avoid conflicts, we probably need to specify full paths and
full names. *sigh*
And yet another one: the behavior of ld, say search order of lib paths
and available options is platform dependend, so when you use option -K
you have no luck on Mac OS X.
Andreas
I would appreciate it if Xcode could manage this for us.
Indeed.
- Steve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
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