The cl65 utility is able to do all of the steps described above, in just one command line, and it has defaults for some options that are very well-suited for our example.
To compile both files into one executable, enter:
cl65 -O -I ../../include -L ../../lib hello.c text.s
(The -I
option is not needed if you are working under a Unix-like system
with the include files in their default path, or if the CC65_INC
environment variable is set correctly. The -L
option is not needed if the
libraries are in their default path, or if the CC65_LIB
environment
variable is set correctly. [Those two environment variables should be set to
absolute paths.])
The cl65 utility knows how to translate C files into object files (it will call the compiler, and then, the assembler). It does know also how to create object files from assembly files (it will call only the assembler, for that). It knows how to build an executable (it will pass all object files to the linker). And finally, it has the C64 as a default target, and will supply the correct startup file and runtime library names to the linker, so you don't have to care about that.
The one-liner above should give you a C64 executable named "hello
" in the
current directory.
For more information about the compile & link utility, see cl65.html.