This problem showed up in a much larger system of dylib's, but I boiled
it down to this small example:
I have three projects each of which creates a Mach-O dylib. I am
linking against the BSD run time stuff. Prebinding is turned off
everywhere. All globals are exported. Let us call the projects A, B
and C. In A.dylib is defined a single function which is called by a
function in B.dylib. So B.mcp includes A.dylib. It compiles and links
fine. C.dylib defines a function which calls calls both A and B's
functions. So the C project includes both A.dylib and B.dylib. This
works as long as A.dylib is not after B.dylib in the Link Order. If it
is I get a link error:
Link Error : undefined: 'myfuncA' (code)
Referenced from 'myfuncC' in c.c
Now if I make the B function so it does not depend on myfuncA, but
leave A.dylib in the B project the same error occurs. But if I then
take A.dylib out of the B project, without changing C.mcp, the link
error in C.mcp goes away.
I would think you could take A.dylib out of C.mcp, since it is already
present in B.dylib which is in C.mcp, but that doesn't work. The A
symbol is undefined.
Now, to make things interesting, in my real situation, which is all C++
code and lots more files, but has the same dependency structure, (B
depends on A, and C depends on them both), when building C, I get
undefined symbols for A or B depending on which is last in the Link
Order for C. It doesn't matter where they are in the Link order
relative to anything else. The symbols from the dylib which is last in
the link order can't be found during the link.
Any help will be much appreciated.
------
If this problem sounds familiar, it is because I posted this same
message about a year ago. I got no responses. I solved the problem then
by just throwing everything into one really big dynamic library. But
now that library is so large that I get a system error when my
application starts up. So without a solution here we will have to
abandon our Codewarrior build and just use Xcode.
Robert
Robert - 15 Mar 2006 16:13 GMT
Ah, forget it.
We are dropping support for Codewarrior builds. Our Xcode build system
is much nicer and we can also do command line configure/make builds. It
isn't worth the hassle anymore.
It's been fun!
Robert