【问题标题】:Compile Header Files编译头文件
【发布时间】:2015-02-12 08:52:02
【问题描述】:

我有以下文件要编译:

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 连接,因此它提供了附加功能。

谁能告诉我如何编译这个?

格鲁斯,安德烈

【问题讨论】:

  • 不是所有你链接在一起的文件最终“连接”了吗?头文件和源文件实际上并没有以那种方式连接。

标签: c compilation makefile header


【解决方案1】:

改变这个:

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

【讨论】:

  • 仍然报错“cc: fatal error: cannot specify -o with -c, -S or -E with multiple files”
猜你喜欢
  • 2010-11-20
  • 2012-07-09
  • 2020-09-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多