On Aug 24, 2005, at 8:47 PM, Andrew Pontious wrote: On Aug 24, 2005, at 2:50 PM, Peter Lau wrote: while reading the "Porting CodeWarrior Projects to Xcode", it has a box which says:
"Important: Static libraries currently will not be linked in Xcode unless they are named according to the format lib*.a. That is, they must start with lib and have the extension .a.".
That does not seem to be our experience with XCode 2.1, has the restriction been removed?
It's a little complicated. ;-)
If you look at the ld (linker) manpage, you can see this:
-lx This option is an abbreviation for the library name `libx.a', where x is a string. If -dynamic is specified the abbreviation for the library name is first search as `libx.dylib' and then `libx.a' is searched for. ld searches for libraries first in any directories specified with -L options, then in the standard directories /lib, /usr/lib, and /usr/local/lib
Let's say you include a library in your Xcode project, and you add it to the "Link Binaries With Libraries" build phase of one of your targets.
If the library's name is of the form 'libXXX.a' or 'libXXX.dylib', we pass the library name to the linker in the format -lXXX, so that you get the flexibility of the search behavior described above.
if the library *doesn't* have that naming convention, we pass in the full path to the library to the linker. So you don't get the same flexibility - linking will only work if that library is really at exactly the path it was at when you added it to Xcode - but the linker can find the library and do the right thing with it, regardless of the library's name.
Hope that helps,
Thanks for the explanation... so basically the naming convention would allow ld to search in various locations, otherwise, it will only see an absolute path?
while it's good to know, I don't see it as critical as it's documented. (The way it's documented or the way I read it as I HAVE TO follow the naming convention or it just wouldn't work).
It kind of work like any file reference to the project window anyway... for example, when I create a sample Carbon app and moved the main.c from within the project folder to project folder/src, XCode can't find it either. So, it's kind of the same user experience... I drag the static lib that's already reference in project window around, I broke the build process.
Anyway, I will stay with libXXX.a format... so everything I wrote means nothing. :-)
Thanks again for the explanation and I found this stuff fascinating, from my over an decade of other IDE experience. :-)
pete
|