dbuchwald / 6502

DB6502: 65C02 based computer inspired by BE6502

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

help compiling .c files

mattmi91 opened this issue · comments

I am unsure how to compile the .c files in the 6502 projects ROM folder im not sure what to use crygwin? cc65? and what commands do I type into these to compile the .C file into an .out file ive been looking on the internet for days and cannot find anything Im looking for, so some pointers on how to do this would be appreciated :)

Every project has a Makefile, so running make clean all should do it for you. It does use cc65, so that needs to be in your path as does GNU Make. I found that Dawid's makefiles don't work well under Windows, so he uses Cygwin.

Instructions to get setup are here, https://github.com/dbuchwald/6502/blob/master/Software/README.md#setting-up-development-environment-under-windows

I have tried using cygwin and I did install all the packages he said too but not sure what to type to make the .out file? he doesnt how other then just basics on what to do when you first install it which I already did but what do I type in the terminal something like g++ lcdtest.c? tried this and got like 50 errors

Did you try typing make clean all?

I get this when I type that make: *** No rule to make target 'clean'. Stop.

ok so I fixed the make file issue but when I do g++ 4bitlcd.s
$ g++ 4bitlcd.s
4bitlcd.s: Assembler messages:
4bitlcd.s: Warning: end of file not at end of a line; newline inserted
4bitlcd.s:1: Error: unknown pseudo-op: .setcpu' 4bitlcd.s:2: Error: can't open lcd.inc for reading: No such file or directory 4bitlcd.s:3: Error: unknown pseudo-op: .segment'
4bitlcd.s:9: Error: unknown pseudo-op: .code' 4bitlcd.s:12: Error: no such instruction: jsr _lcd_init'
4bitlcd.s:14: Error: no such instruction: write_lcd ' 4bitlcd.s:16: Error: no such instruction: ldx '
4bitlcd.s:18: Error: no such instruction: lda chars_msg,x' 4bitlcd.s:19: Error: no such instruction: beq end_loop'
4bitlcd.s:20: Error: no such instruction: jsr _lcd_print_char' 4bitlcd.s:21: Error: no such instruction: inx '
4bitlcd.s:22: Error: no such instruction: bra char_loop' 4bitlcd.s:24: Error: no such instruction: bra end_loop'
4bitlcd.s:26: Error: unknown pseudo-op: `.segment'

make builds all the files, you don't call g++. The file that you are trying to compile is assembly language, not C++, so it is assembled by cc65, but you don't have to call that either, make all does that for you and puts the output in a build or bin folder.

Just switch to the Software directory and type make clean all. That's it, nothing more, it will build everything.

I should add that you can't build most of the individual files in this repo and get a runnable program. Almost all of them include files in the common directory, that is why you need the Makefile, to coordinate the building and linking of all the files.

so im in the directory of where that c file is and when I type make all I get already a directory message also should I be in a specific folder? like cc65 folder? and what do I type in the terminal to compile any make command just says already a directory or it cant do it for whatever reason

im just trying to get the a.out file from these so I can program it into my eeprom

As I said,

Just switch to the Software directory and type make clean all. That's it, nothing more, it will build everything.

Then look in the build folder that is created.

did what you said and here is the error that I got
$ make clean all
rm -rf build
make -C rom/01_nop_fill ADDRESS_MODE=ext all
make[1]: Entering directory '/home/matthew/6502-master/software/rom/01_nop_fill'
ca65 --cpu 65C02 -Dclock_mode_flag=2 -Dacia_tx_irq=0 -Ddb6502 -I ../../common/include -o ../../build/common/zeropage.o -l ../../build/common/zeropage.lst ../../common/source/zeropage.s
make[1]: ca65: No such file or directory
make[1]: *** [../../common/makefile:184: ../../build/common/zeropage.o] Error 127
make[1]: Leaving directory '/home/matthew/6502-master/software/rom/01_nop_fill'
make: *** [makefile:76: build/rom/01_nop_fill.ext.bin] Error 2

tried under the first clean all test he mentions in the rom folder
$ make clean all
rm -f ../../build/rom/.bin
rm -f ../../build/rom/
.raw
../../build/rom/01_nop_fill/.o
../../build/rom/01_nop_fill/
.lst
../../build/rom/01_nop_fill/.s
../../build/rom/01_nop_fill/
.map
../../build/common/.o
../../build/common/
.lst
../../build/common/.s
../../build/lib/
.lib
ca65 --cpu 65C02 -Dclock_mode_flag=2 -Dacia_tx_irq=0 -Ddb6502 -I ../../common/include -o ../../build/common/zeropage.o -l ../../build/common/zeropage.lst ../../common/source/zeropage.s
make: ca65: No such file or directory
make: *** [../../common/makefile:184: ../../build/common/zeropage.o] Error 127

tried putting ca65 folder inside this and that did not work either

  1. make clean fails if you have not built before and the build directory does not exist. In that case make all will do.
  2. To solve your error ca65 needs to be added to your path. Google how to do that in Cygwin, I think you add it to your .bashrc file but I don't use Cygwin. If you can type ca65 at the command line without errors, then make will work.

tried adding the path in my system variables
C:\cygwin64\home\matthew\6502-master\Software\ca65
of course did not work -_- this is why I hate dealing with software so irritating lol

If you are using cygwin, that isn't a correct Linux path. Try ~/6502-master/Software/ca65

im using cygwin on windows 10

did you look in the folders under build/roms? I saw them being created in the output you sent.

thanks for the help with the advice of getting that make clean all command, the fix was I had to put cc65 exe files inside the cygwin64 bin folder then it worked it was a lucky guess but I got it :)

Excellent, happy 8-bit computing. Can you close this issue? Only you or @dbuchwald can.

maybe it would help someone else that has similar problem?

It may help someone else, but they will still be able to find it in search. It is normal in GitHub to close issues that are resolved or the questions answered.