编译头文件

时间:2015-02-12 08:52:02

标签: 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连接,因此它提供了额外的功能。

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

Gruß,Andre

1 个答案:

答案 0 :(得分:0)

改变这个:

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添加到要链接的对象列表中。