intro-4.html

来自「cc65 的编译器文档」· HTML 代码 · 共 56 行

HTML
56
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML><HEAD> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.20"> <TITLE>cc65 compiler intro: The linker</TITLE> <LINK HREF="intro-5.html" REL=next> <LINK HREF="intro-3.html" REL=previous> <LINK HREF="intro.html#toc4" REL=contents></HEAD><BODY><A HREF="intro-5.html">Next</A><A HREF="intro-3.html">Previous</A><A HREF="intro.html#toc4">Contents</A><HR><H2><A NAME="s4">4.</A> <A HREF="intro.html#toc4">The linker</A></H2><P>The linker combines several object and library file into one output file. ld65is very configurable, but fortunately has a builtin configuration for the C64,so we don't need to mess with configuration files here.</P><P>The compiler uses small functions to do things that cannot be done inlinewithout big impact on code size. These runtime functions, together with the Clibrary are in an object file archive named after the system, in this case"<CODE>c64.lib</CODE>". We have to specify this file on the command line so that thelinker can resolve these functions.</P><P>A second file (this time an object file) needed, is the startup code thatprepares the grounds for the C program to run. The startup file must beexecuted first, so it must be the first file on the linker command line.</P><P>Let's link our files to get the final executable:</P><P><BLOCKQUOTE><CODE><PRE>        ld65 -t c64 -o hello c64.o hello.o text.o c64.lib</PRE></CODE></BLOCKQUOTE></P><P>The argument after <CODE>-o</CODE> specifies the name of the output file, the argumentafter <CODE>-t</CODE> gives the target system. As discussed, the startup file must bethe first file on the command line (you may have to add a path here, if<CODE>c64.o</CODE> is not in your current directory). Since the library resolvesimports in <CODE>hello.o</CODE> and <CODE>text.o</CODE>, it must be specified <EM>after</EM> thesefiles.</P><P>After a successful linker run, we have a file named "<CODE>hello</CODE>", ready forour C64!</P><P>For more information about the linker see <A HREF="ld65.html">ld65.html</A>.</P><HR><A HREF="intro-5.html">Next</A><A HREF="intro-3.html">Previous</A><A HREF="intro.html#toc4">Contents</A></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?