Trouble with nes.lib

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
radishking27
Posts: 13
Joined: Mon Mar 25, 2019 10:58 am

Trouble with nes.lib

Post by radishking27 »

I'm in NESICIDE and i'm trying to test-compile Alter Ego but the nes.lib, according to the log, says the add.o is at a different version or something. I tried downloading a new library but now the error comes up as:

Code: Select all

ld65: Error: Wrong data version in 'nes.lib'
If anyone knows how to deal with this, please let me know.
User avatar
Banshaku
Posts: 2417
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Re: Trouble with nes.lib

Post by Banshaku »

My guess would be that alter ago, since it's was released a long time ago, is using a version of neslib compiled with a older version of cc65. Since there is a good chance that NESICIDE is using a more recent version, you will need to compile neslib yourself. I remember having such issues at first when trying to use Shiru's example with the latest version (2.17) of cc65 when the examples were targeted for, hmm, 2.14 I think.
radishking27
Posts: 13
Joined: Mon Mar 25, 2019 10:58 am

Re: Trouble with nes.lib

Post by radishking27 »

Banshaku wrote:My guess would be that alter ago, since it's was released a long time ago, is using a version of neslib compiled with a older version of cc65. Since there is a good chance that NESICIDE is using a more recent version, you will need to compile neslib yourself. I remember having such issues at first when trying to use Shiru's example with the latest version (2.17) of cc65 when the examples were targeted for, hmm, 2.14 I think.
Question is how do I compile a neslib? Do i just stick it through ca65 or ld65 or do i just put it through a special compiler?
User avatar
Banshaku
Posts: 2417
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Re: Trouble with nes.lib

Post by Banshaku »

It depends what nes.lib represents in that case. The last time I checked those sample it was almost a year ago so my memory is quite fuzzy about it. I think in that case it would be the C runtime, which you need to rebuild with ca65/cc65, which is not obvious is you just started worked on the nes or have never worked with cc65 directly.

I will check what was nes.lib for alter ego and let you know later.

edit:

I confirmed and nes.lib is the C runtime and alter ago provides a version for cc65 he used at the time. You will need to rebuild that file, which I did once and is a barebone set of the C library but I don't have the commands in front of me to do it. There was a sample I shared last year on nesdev that should allow to re-create it and may contain the sample with it. I will see if I can find the link and add it to this post later.

edit2:

This post contain a makefile with example1.c from Shiru's samples:
https://forums.nesdev.com/viewtopic.php?f=2&t=17467

It should work under linux/macos and once compiled, it should create the example and runtime. CC65 needs to be in your path, if not, just update the paths inside the makefile.

Instead of nes.lib, it will create a file called runtime.lib which you should be able to rename to nes.lib and use with alter ego sample.
User avatar
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Re: Trouble with nes.lib

Post by cpow »

radishking27 wrote:Question is how do I compile a neslib? Do i just stick it through ca65 or ld65 or do i just put it through a special compiler?
If I recall, the changes Shiru made to the lib weren't API-breaking thus the original nes.lib that comes with cc65 toolchain "works".
I also found that the libs built with the latest toolchain have a segment called ONCE that looks to have replaced the segment called INIT. Modifying the nes.cfg linker script in this regard, and removing the nes.lib from the project (to force it to use the one that comes with the toolchain) leads to a successful build and run of AlterEgo in nesicide.

I've uploaded the modified AlterEgo project here.
I'll have to dig to find out what Shiru changed in the nes.lib, but the game runs.
Post Reply