EvilActivity Posted May 24, 2015 Share Posted May 24, 2015 (edited) Hey guys, I've done some makefile upgrading so I have sprite-sheets automatically sliced up and converted into objects. This caused me to end up with a lot of objects (each sprite a separate object), which had me end up with the 'too many objects' error when linking with CL65. Is there a way to merge the objects together before linking them? I was hoping to avoid rewriting the makefile so I have the sprpck sprite output files compiled into one object file, but all searches seem to point into that direction since I can't find any documentation on it. (I believe gcc would have something along the lines of -r/-relocatable). Cheers! Edited May 24, 2015 by EvilActivity Quote Link to comment Share on other sites More sharing options...
+karri Posted May 25, 2015 Share Posted May 25, 2015 The way to handle this is to write the objects into a file. In my Makefile every directory participating in the game creates a list of object files like this all: $(objects) $(TOUCH) objlist $(RM) objlist for obj in $(objects); do $(ECHO) ../intro/$$obj >> objlist; done In the linking phase I then use something like this: others = \ @../resident/objlist \ @../bitmaps/objlist \ @../shaken/objlist \ @../sounds/objlist \ @../intro/objlist \ @../driving/objlist \ all: $(target) $(target) : $(objects) $(objlists) $(CL) -t $(SYS) -o $@ -m lynx.map -C lynx.cfg $(objects) $(others) lynx.lib This is one way to get arount the limitation of too many object files. Another way is to add them to your own library. Quote Link to comment Share on other sites More sharing options...
EvilActivity Posted May 25, 2015 Author Share Posted May 25, 2015 (edited) That doesn't seem to do the trick for me: d:/Projects/Lynx/CC65/bin/cl65 -t lynx -o game.lnx lynx.lib @obj/objlist ld65: Error: Too many input files There are 334 object files in the obj/objlist btw. I'll try it with a library instead :-) Edited May 25, 2015 by EvilActivity Quote Link to comment Share on other sites More sharing options...
EvilActivity Posted May 25, 2015 Author Share Posted May 25, 2015 It seems that the linker can't find my sprite data when I put it in a library. Is there something special I need to do before the sprites within a library can be detected? The library is created through "ar65 a sprite.lib sprite.o", while the linker is called with: "cl65 -t lynx -o game.lnx lynx.lib sprite.lib <extra-.lib/.o> game.o". The sprites are created as they are in LX.NET's tutorial, an assembly file created that contains: .global _sprite .segment "RODATA" _sprite: .incbin "sprite.spr" Which is then assembled into an object with "ca65 -t lynx -o sprite.o sprite.s" But in the end I get the unresolved external reference: Unresolved external `_sprite' referenced in: game.s(36) ld65: Error: 1 unresolved external(s) found - cannot create output file Quote Link to comment Share on other sites More sharing options...
+karri Posted May 26, 2015 Share Posted May 26, 2015 The linking order may be important. Put the sprites,lib after game.o You could also try to split the @objlist files into two separate entries like @objlist1 @objlist2. There may be some internal line count limits that cause problems. Quote Link to comment Share on other sites More sharing options...
EvilActivity Posted May 26, 2015 Author Share Posted May 26, 2015 The linking order may be important. Put the sprites,lib after game.o You could also try to split the @objlist files into two separate entries like @objlist1 @objlist2. There may be some internal line count limits that cause problems. Oh wow, the order did matter indeed. I thought putting them in front of the object that needs it would make more sense than putting it after it. Thanks karri! Quote Link to comment Share on other sites More sharing options...
Shawn Jefferson Posted May 27, 2015 Share Posted May 27, 2015 It looks like the limit for ld65 is 256 files. https://github.com/cc65/cc65/blob/master/src/ld65/main.c Check MAX_INPUT_FILES. Quote Link to comment Share on other sites More sharing options...
EvilActivity Posted May 27, 2015 Author Share Posted May 27, 2015 It looks like the limit for ld65 is 256 files. https://github.com/cc65/cc65/blob/master/src/ld65/main.c Check MAX_INPUT_FILES. Ah nice, although I'm not going to change anything in the tools, good to know the actual limit. Having the sprites put in a library works perfect. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.