Re: Linking and cross-referenced static libraries
Re: Linking and cross-referenced static libraries
- Subject: Re: Linking and cross-referenced static libraries
- From: Adam Zegelin <email@hidden>
- Date: Wed, 18 Jul 2007 22:45:51 +1000
On 17/07/2007, at 3:49 AM, Rush Manbert wrote:
Adam Zegelin wrote:
Hi,
I'm currently working on porting a Win32 project that splits
up individual components into static libraries, all of which are
linked together into the final executable. Each static library
references symbols defined in the other components. The Win32
version (which is compiled with MSVC 2005 via perl scripts) links
each separate component into the final executable in an arbitrary
order (atm, i think its alphabetical). MSVC's linker has no
complaints about this and resolves all the external symbols in
each static library correctly.
However the same project compiled with Xcode (or gcc
directly via the command line) results in errors from ld. It
complains about the link order, which, while I have found the
order required, is confusing to me. Is there anyway to tell ld to
ignore the order of the libraries?
I don't see any replies to this, so I'll try to break the bad news
gently. :-)
The GNU linker only reads each static library once, in the order in
which the libraries are specified on the command line. Thus, cross-
references between libraries can be a big headache. You can specify
a library on the linker command line more than once, and each time
its name is encountered, the linker will read it and attempt to
resolve outstanding external references. If you have a Xcode
project you can do this by using the "Other Linker Flags" build
setting.
The Microsoft linker, on the other hand, reads the libraries more
than once if necessary, or uses some other method to resolve
external references, even if a number of libraries are cross-
referenced. I have the impression, from reading people's moan and
groan posts, that the Code Warrior linker did the same, but I have
no direct experience, and it doesn't matter now because Xcode/GNU
is The Way.
- Rush
Thanks for the help. I've ended up specifying the libraries multiple
times and that solves the problem.
—
Adam Zegelin
_______________________________________________
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