【问题标题】:makefile with multiple files and dependencies具有多个文件和依赖项的 makefile
【发布时间】:2013-04-03 15:55:26
【问题描述】:

我知道这个 makefile 非常简单,但我一直在阅读一些教程和示例来尝试学习和应用它。 我展示的内容是否有问题,或者这是否应该与我展示的包含一起使用?

所有文件都位于运行 make 的 CWD 中。


这是我的依赖项列表。

CT.c includes: studio.h, math.h, "CT.h", "TM.h"
CT.h includes: none
TM.c includes: "TM.h", stdio.h, math.h
TM.h includes: none
RP.c includes: "CT.h", math.h, fftw3.h, stdio.h, stdlib.h, "TM.h"
RP.h includes: fftw3.h
RF.c includes: "RF.h", stdlib.h, stdio.h
RF.h includes: none
DR.c includes: stdio.h, math.h, "DR.h"
main.c includes: "CT.h", "DR.h", "TM.h", "RP.h", "RF.h", stdio.h, math.h, time.h, stdlib.h, fftw3.h

这是我的 makefile 不工作:

RFST: main.o CT.o TM.o RP.o RF.o DR.o
        gcc -L/home/me/projects/RFST/libs -o RFST main.o CT.o TM.o RP.o RF.o DR.o -lfftw3 -lasc -lmfhdf -ldf -lz -ljeg -lm
main.o: main.c CT.h TM.h RP.h RF.h DR.h
        gcc -I. -c main.c
CT.o: CT.c CT.h TM.h
        gcc -I. -c CT.c
TM.o: TM.c TM.h
        gcc -I. -c TM.c
RP.o: RP.c RP.h CT.h TM.h
        gcc -I. -c RP.c
RF.o: RF.c RF.h
        gcc -I. -c RF.c
DR.o: DR.c DR.h
        gcc -I. -c DR.c

当尝试运行 makefile 时,它​​抱怨没有声明一些东西,但是所有这些东西都在包含的各种头文件中声明。

例子:

'vA' undeclared(first use in this function)
'Variables' undeclared(first use in this funcion)

Variables vA[]; 在 main.c 中。 VariablesDR.h 中的 struct,它被包含在 main.c 中。

【问题讨论】:

  • 你的错误信息是什么?
  • 为什么 .h 文件在必需列表中?如果缺少头文件,您的 .c 文件将无法编译。
  • @gongzhitaao,添加示例错误。
  • @dbasic,你能详细说明一下吗?我不明白你的评论。 “为什么 .h 文件在必需列表中?”
  • 我不认为这是 makefile 的问题。你能告诉我们main.c吗?

标签: c gcc makefile


【解决方案1】:

几个头球后卫打错了。修复这两个标头保护解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-08
    • 2011-07-26
    • 1970-01-01
    • 2020-09-03
    • 2017-04-11
    • 1970-01-01
    • 1970-01-01
    • 2017-06-29
    相关资源
    最近更新 更多