[cc65] Linker feature (was: linker bug)

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2006-04-27 22:49:22
On Thu, Apr 27, 2006 at 10:20:48AM -0400, Andrew J. Kroll wrote:
> The problem is that ld65 sees _main only in object files. It should really
> not matter if it is inside an archive either. The bug was found while
> I was tring to link together a program that has a rather large amount of
> object files, and it is a speedup and easier to link up from a single
> archive of routines than 30 files.

It's not a bug, it's a feature:-)

By default, libraries are only searched once. The problem with your library
is, that when the linker sees it, there is no reference to a symbol named
_main. This reference is in the runtime library, which is last on the command
line, so it is searched at a time, when the linker has already decided it
doesn't need your module hello.o, containing the symbol _main. You can see
that from the linker error message

Unresolved external `_main' referenced in:
  callmain.s(11)

callmain.s is none of your modules, so it must be in the runtime library
(c64.lib or whatever).

To solve the problem, you need to change the linker search strategy. Within a
library group, the linker will repeatedly search all libraries until all
symbols are resolved. So all you have to do is to change the command line and
place both libraries into one library group:

        ld65 -t c64 -o hello c64.o -\( hello.lib c64.lib -\)

(you do not need the backslashes before the parens when using DOSish operating
systems).

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Apr 27 22:49:41 2006

This archive was generated by hypermail 2.1.8 : 2006-04-27 22:49:44 CEST