Help with cc65 suite and libraries (answered)

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Post Reply
GlennSmith
Posts: 162
Joined: 26 Dec 2002
Location: Occitanie, France

Help with cc65 suite and libraries (answered)

Post by GlennSmith »

Hi all,
The PLASMA evaluation got put to the side for the moment - I have another (what was supposed to be little) project on the go at the moment...
I need to use the cc65 suite to compile & run a short program that was provided by one of my sons. The program works a treat compiled on linux (with gcc) and I wanted to show him what it looked like in 6502 lingo... His coding is OK, and the cc65 compiler doesn't complain about anything.
So far, so good...
I thought that this would be a good time to put my new 65C02 Picocomputer through some hoops. So my cc65 now has the rp6502 target in place, I have the .cfg file, etc.
When I try linking the whole thing together, the linker complains about tons of unresolved externals, like "tosaddax", "tosgeax"... These are helper shims that are in the runtime library. Normally the <target>.lib library file is actually a merge of the runtime library AND the <target>'s specific routines. And, if I look at the rp6502.lib file with a hex editor, I can see the different exports of all of the "missing" externals.
So, what am I missing, or doing wrong ?
Please help, my "Dad always wins" score is dwindling fast.
P.S. This is the sequence of compiling

Code: Select all

cc65 -t none --cpu 65c02 greg.c
ca65 --cpu 65c02 greg.s
ca65 --cpu 65c02 crt0.s
ca65 --cpu 65c02 ria.s
ca65 --cpu 65c02 oserror.s
ld65 -v --allow-multiple-definition --target rp6502 --lib rp6502.lib -m greg.map crt0.o ria.o oserror.o greg.o
Last edited by GlennSmith on Tue Aug 27, 2024 5:21 pm, edited 1 time in total.
Glenn-in-France
User avatar
8BIT
Posts: 1787
Joined: 30 Aug 2002
Location: Sacramento, CA
Contact:

Re: Help with cc65 suite and libraries

Post by 8BIT »

Hi Glenn,

I'm am not an expert on CC65, but I did manage to build new targets supporting some of my projects.

After compiling the new library, I would use the cl65 command line to build an application. here's a copy of my DOS batch file:

Code: Select all

set CC65LIB=c:\cc65\lib
cl65 -t none -C avrr.cfg -o enet -m enet.map -l %CC65LIB%\avrr.o main.c uip.c uip_arch.c appcall.c httpd.c fs.c cgi.c uip_arp.c enceth.s adc.c %CC65LIB%\avrr.lib
I used "-t none" because I was using a direct reference to my cfg file "-C avrr.cfg" You cannot use both.

The "-o enet" defines the output file

The "avrr.o" file is the same as "crt0.o" ( I just rename to match the library file as I build it when I build the library)

Notice you can mix .c and .s files in the source list.

This would work for me. If you want to post a zip of all your source and library files, I can try to compile them and figure out what might be wrong or missing.

Daryl
Please visit my website -> https://sbc.rictor.org/
resman
Posts: 154
Joined: 12 Dec 2015
Location: Lake Tahoe
Contact:

Re: Help with cc65 suite and libraries

Post by resman »

Try reordering your .o and library files in the command line. Put the the .o files you compiled first, then the pre-built .o and library files last. You want the references to search from left to right. Something like:

Code: Select all

ld65 -v --allow-multiple-definition --target rp6502 -m greg.map  greg.o ria.o oserror.o  crt0.o --lib rp6502.lib
GlennSmith
Posts: 162
Joined: 26 Dec 2002
Location: Occitanie, France

Re: Help with cc65 suite and libraries

Post by GlennSmith »

resman wrote:
Put the the .o files you compiled first, then the pre-built .o and library files last. You want the references to search from left to right.
Just plain magic !
Thanks man!
Glenn-in-France
resman
Posts: 154
Joined: 12 Dec 2015
Location: Lake Tahoe
Contact:

Re: Help with cc65 suite and libraries (answered)

Post by resman »

I just want you to get back to PLASMA ;-)
Post Reply