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,
-- Andrew Pontious |