编译头文件

标签 c compilation makefile header

我有以下文件要编译:

cc -g    -c -o add_clnt.o add_clnt.c
cc -g    -c -o add_client.o add_client.c initfunction.c
cc -g    -c -o add_xdr.o add_xdr.c
cc -g    -o add_client  add_clnt.o add_client.o add_xdr.o -lnsl
cc -g    -c -o add_svc.o add_svc.c
cc -g    -c -o add_server.o add_server.c
cc -g    -o add_server  add_svc.o add_server.o add_xdr.o -lnsl

但这不可能,因为我收到以下错误:

cc -g    -c -o add_clnt.o add_clnt.c
cc -g    -c -o add_client.o add_client.c initfunction.c
cc: fatal error: cannot specify -o with -c, -S or -E with multiple files
compilation terminated.
make: *** [new] Fehler 1

initfunction.c 通过 initfunction.h 与 add_client.c 连接,因此它提供了附加功能。

有人可以告诉我如何编译它吗?

安德烈·格鲁斯

最佳答案

更改此:

cc -g    -c -o add_client.o add_client.c initfunction.c

cc -g    -c -o add_client.o add_client.c 
cc -g    -c -o initfunction.o initfunction.c

然后将 initfunction.o 添加到要链接的对象列表中。

关于编译头文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28473037/

相关文章:

java - C 进程和 JAVA 应用程序之间的 FIFO 问题

c - 跨大型和小型 Endian 机器的数据传输

将一个 9 位数字转换为三个 3 位数字

c++ - 在 Windows 上包含 sys/times.h 的替代方法是什么?

linux - *.dsc 文件与 *.deb 和源代码文件的关系

c - 终端C程序输入文件

makefile - make 无法使用 openssl 构建 squid(使用了已弃用的函数)

Makefile 子目录中的多个目标

image - 如何使用带有 Inkscape 的 Makefile 保存为 "Plain SVG"

android - 警告 : API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'