Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我有 ao、bo 和 co,我如何让 ld 将它们链接到 do,然后链接到我的主目标文件中?我想要发生的就是将输入文件中的所有符号组合成一个大的输出文件。
找到了。-r 选项以增量方式链接文件,因此它们可以用作 ld 的输入。
.o 文件的串联称为库。您可以使用ar库实用程序创建一个:
ar rvs mylib.a a.o b.o c.o
然后,您可以链接到库:
cc main.c mylib.a