Thanks to Scott Johnson for his reply to my posting.
> > Project Type = Library, and the PalmOS Library button is set. This
> > library contains more than 64K of executable code, so I created a
> > number of segments in the foo.mcp project and partitioned the object
> > files among them so that each segment is at most 64K in size.
>
> That has no effect when building a static library, because a library
> isn't an executable (.prc) with code resources. It's basically just a
> bunch of compiled functions clumped together, with no size limit. None
> of this 64K limit stuff happens until you later build the final .prc,
> when the linker tries to put everything together.
>
> (The docs and the IDE don't exactly make this obvious.)
Thanks for the clarification. You're right that the docs and the IDE don't help
much here.
> > so I now have a .prc file which won't load because one of its
> > segments is larger than 64K.
>
> Not helped by the fact the linker doesn't warn you about this.
Yes - the first time I created an application which had more than 64K in a
segment, it linked without warning but I couldn't load it into a device, and I
was stumped for a while. A linker warning would definitely be appropriate.
> > is it just not possible to link in a library which has
> > more than 64K of code?
>
> Almost; technically the linker omits functions which never get called,
> so the library can have way more than 64K of code as long as the
> functions you actually call don't add up to more than 64K. But it
> sounds like you're over 64K either way in this case.
Yes, I'm way over 64K - my library is about 300K in size and I'm pulling in most
of it.
> > Thanks in advance for any advice.
>
> First, why are you building this external library instead of putting all
> files in the .prc project? If it's convenient, just put all source
> files in the .prc project and then you can tweak the segment
> configuration until all is well.
The code in the library is built using somewhat different project settings than
the code in the application, and I potentially want to reuse the code in the
library in a couple of different applications. Eventually I will use a shared
library instead, but that has its own problems which I won't go into here (read:
globals; callbacks; multiple code segments).
> Or if you want to keep those library files external (say for reuse or
> distribution) then you can probably just divide them into two or more
> sub-64K libraries, then add those libs into the .prc in separate
> segments. The linker doesn't care whether your code comes from source
> files in the project, or a single .lib, or multiple .libs.
Unfortunately I would need at least 6 different libraries if I used this
strategy, and they would have to be build as 6 different targets in CodeWarrior.
This would be a nightmare to maintain, since if I ever changed any of the
project settings for one target, I would have to manually change them in all of
the other targets as well (and potentially for both release and debug builds).
-adam