Makefile中的错误:gcc:error:filename.o:没有找到这样的文件或目录

问题描述:

我有以下的makefile,但是当我将它编译为时出现错误:找不到这样的文件或目录。 这是我正在执行的makefile: P.S.我正试图在Linux和Windows上执行此操作,但两者都出现同样的错误。Makefile中的错误:gcc:error:filename.o:没有找到这样的文件或目录

CC = gcc 
#LFLAG = 
CFLAGS = -Wall -g -O4 -DWMOPS=0 -D__MSDOS__ 

# Objects 
OBJ = coder.o agc2.o autocorr.o az_isp.o bits.o c2t64fx.o c4t64fx.o cod_main.o \ 
    convolve.o cor_h_x.o d2t64fx.o d4t64fx.o decim54.o dec_main.o deemph.o \ 
    dtx.o d_gain2.o gpclip.o g_pitch.o hp6k.o hp7k.o hp50.o hp400.o hp_wsp.o \ 
    int_lpc.o isfextrp.o isp_az.o isp_isf.o lagconc.o lag_wind.o levinson.o \ 
    lp_dec2.o math_op.o ph_disp.o pitch_f4.o pit_shrp.o pred_lt4.o preemph.o \ 
    p_med_ol.o qisf_ns.o qpisf_2s.o q_gain2.o q_pulse.o random.o residu.o \ 
    scale.o syn_filt.o updt_tar.o util.o voicefac.o wb_vad.o weight_a.o \ 
    basicop2.o count.o log2.o oper_32b.o homing.o \ 

DOBJ = decoder.o agc2.o autocorr.o az_isp.o bits.o c2t64fx.o c4t64fx.o cod_main.o \ 
    convolve.o cor_h_x.o d2t64fx.o d4t64fx.o decim54.o dec_main.o deemph.o \ 
    dtx.o d_gain2.o gpclip.o g_pitch.o hp6k.o hp7k.o hp50.o hp400.o hp_wsp.o \ 
    int_lpc.o isfextrp.o isp_az.o isp_isf.o lagconc.o lag_wind.o levinson.o \ 
    lp_dec2.o math_op.o ph_disp.o pitch_f4.o pit_shrp.o pred_lt4.o preemph.o \ 
    p_med_ol.o qisf_ns.o qpisf_2s.o q_gain2.o q_pulse.o random.o residu.o \ 
    scale.o syn_filt.o updt_tar.o util.o voicefac.o wb_vad.o weight_a.o \ 
    basicop2.o count.o log2.o oper_32b.o homing.o \ 

# Implicit Rules 
.c.o: 
    $(CC) $(CFLAGS) -c $< 

all: coder decoder 

# Explicit Rules 
coder: $(OBJ) 
    $(CC) $(CFLAGS) -o coder $(OBJ) 
decoder: $(DOBJ) 
    $(CC) $(CFLAGS) -o decoder $(DOBJ) 

# Individual File Dependencies 

basicop2.o: typedef.h basic_op.h count.h 
count.o: typedef.h count.h 
log2.o:  log2.h typedef.h basic_op.h count.h log2_tab.h 
oper_32b.o: typedef.h basic_op.h oper_32b.h count.h 
autocorr.o: typedef.h basic_op.h oper_32b.h acelp_fx.h count.h 
az_isp.o: typedef.h basic_op.h oper_32b.h count.h 
bits.o:  typedef.h basic_op.h cnst_fx.h bits_fx.h acelp_fx.h count.h dtx_fx.h 
c2t64fx.o: typedef.h basic_op.h math_op.h acelp_fx.h count.h cnst_fx.h 
c4t64fx.o: typedef.h basic_op.h math_op.h acelp_fx.h count.h cnst_fx.h q_pulse_fx.h 
cod_main.o: typedef.h basic_op.h oper_32b.h math_op.h cnst_fx.h acelp_fx.h \ 
    cod_main_fx.h bits_fx.h count.h 
convolve.o: typedef.h basic_op.h count.h 
cor_h_x.o: typedef.h basic_op.h math_op.h count.h 
d2t64fx.o: typedef.h basic_op.h count.h cnst_fx.h 
d4t64fx.o: typedef.h basic_op.h count.h cnst_fx.h q_pulse_fx.h 
decim54.o: typedef.h basic_op.h acelp_fx.h count.h cnst_fx.h 
dec_main.o: typedef.h basic_op.h oper_32b.h cnst_fx.h acelp_fx.h dec_main_fx.h bits_fx.h count.h math_op.h 
deemph.o: typedef.h basic_op.h math_op.h count.h 
dtx.o:  typedef.h basic_op.h oper_32b.h math_op.h cnst_fx.h acelp_fx.h bits_fx.h dtx_fx.h count.h log2.h 
d_gain2.o: typedef.h basic_op.h oper_32b.h math_op.h log2.h cnst_fx.h acelp_fx.h count.h 
gpclip.o: typedef.h basic_op.h count.h 
g_pitch.o: typedef.h basic_op.h math_op.h count.h 
homing.o: typedef.h basic_op.h cnst_fx.h bits_fx.h 
hp400.o: typedef.h basic_op.h oper_32b.h acelp_fx.h count.h 
hp50.o:  typedef.h basic_op.h oper_32b.h cnst_fx.h acelp_fx.h count.h 
hp6k.o:  typedef.h basic_op.h acelp_fx.h count.h cnst_fx.h 
hp_wsp.o: typedef.h basic_op.h oper_32b.h acelp_fx.h count.h 
int_lpc.o: typedef.h basic_op.h cnst_fx.h acelp_fx.h count.h 
isfextrp.o: typedef.h basic_op.h oper_32b.h cnst_fx.h acelp_fx.h count.h 
isp_az.o: typedef.h basic_op.h oper_32b.h count.h cnst_fx.h 
isp_isf.o: typedef.h basic_op.h count.h 
lagconc.o: typedef.h basic_op.h count.h cnst_fx.h acelp_fx.h 
lag_wind.o: typedef.h basic_op.h oper_32b.h 
levinson.o: typedef.h basic_op.h oper_32b.h acelp_fx.h count.h 
lp_dec2.o: typedef.h basic_op.h count.h cnst_fx.h 
math_op.o: typedef.h basic_op.h math_op.h count.h 
ph_disp.o: typedef.h basic_op.h cnst_fx.h acelp_fx.h count.h 
pitch_f4.o: typedef.h basic_op.h math_op.h acelp_fx.h cnst_fx.h count.h 
pit_shrp.o: typedef.h basic_op.h count.h 
pred_lt4.o: typedef.h basic_op.h count.h 
preemph.o: typedef.h basic_op.h count.h 
p_med_ol.o: typedef.h basic_op.h acelp_fx.h oper_32b.h count.h math_op.h 
qisf_ns.o: typedef.h basic_op.h acelp_fx.h count.h 
qpisf_2s.o: typedef.h basic_op.h cnst_fx.h acelp_fx.h count.h 
q_gain2.o: typedef.h basic_op.h oper_32b.h math_op.h count.h log2.h acelp_fx.h 
q_pulse.o: typedef.h basic_op.h count.h q_pulse_fx.h 
random.o: typedef.h basic_op.h count.h 
residu.o: typedef.h basic_op.h count.h 
scale.o: typedef.h basic_op.h count.h 
syn_filt.o: typedef.h basic_op.h math_op.h count.h cnst_fx.h 
updt_tar.o: typedef.h basic_op.h count.h 
util.o:  typedef.h basic_op.h count.h 
voicefac.o: typedef.h basic_op.h math_op.h count.h 
wb_vad.o: cnst_fx.h wb_vad_fx.h typedef.h basic_op.h count.h math_op.h wb_vad_c_fx.h 
weight_a.o: typedef.h basic_op.h count.h 
agc2.o:  cnst_fx.h acelp_fx.h typedef.h basic_op.h count.h math_op.h 
hp7k.o:  typedef.h basic_op.h cnst_fx.h acelp_fx.h count.h 
decoder.o: typedef.h basic_op.h acelp_fx.h cnst_fx.h main.h bits_fx.h dtx_fx.h count.h 
coder.o: typedef.h basic_op.h acelp_fx.h cnst_fx.h cod_main_fx.h bits_fx.h count.h cod_main_fx.h 

确切的错误我得到的是:

make -f makefile.gcc 
gcc -Wall -g -O4 -DWMOPS=0 -D__MSDOS__ -o coder coder.o agc2.o autocorr.o az_isp.o bits.o c2t64fx.o c4t64fx.o cod_main.o convolve.o cor_h_x.o d2t64fx.o d4t64fx.o decim54.o dec_main.o deemph.o dtx.o d_gain2.o gpclip.o g_pitch.o hp6k.o hp7k.o hp50.o hp400.o hp_wsp.o int_lpc.o isfextrp.o isp_az.o isp_isf.o lagconc.o lag_wind.o levinson.o lp_dec2.o math_op.o ph_disp.o pitch_f4.o pit_shrp.o pred_lt4.o preemph.o p_med_ol.o qisf_ns.o qpisf_2s.o q_gain2.o q_pulse.o random.o residu.o scale.o syn_filt.o updt_tar.o util.o voicefac.o wb_vad.o weight_a.o basicop2.o count.o log2.o oper_32b.o homing.o 
gcc: error: coder.o: No such file or directory 
gcc: error: agc2.o: No such file or directory 
gcc: error: autocorr.o: No such file or directory 
gcc: error: az_isp.o: No such file or directory 
gcc: error: bits.o: No such file or directory 
gcc: error: c2t64fx.o: No such file or directory 
gcc: error: c4t64fx.o: No such file or directory 
gcc: error: cod_main.o: No such file or directory 
gcc: error: convolve.o: No such file or directory 
gcc: error: cor_h_x.o: No such file or directory 
gcc: error: d2t64fx.o: No such file or directory 
gcc: error: d4t64fx.o: No such file or directory 
gcc: error: decim54.o: No such file or directory 
gcc: error: dec_main.o: No such file or directory 
gcc: error: deemph.o: No such file or directory 
gcc: error: dtx.o: No such file or directory 
gcc: error: d_gain2.o: No such file or directory 
gcc: error: gpclip.o: No such file or directory 
gcc: error: g_pitch.o: No such file or directory 
gcc: error: hp6k.o: No such file or directory 
gcc: error: hp7k.o: No such file or directory 
gcc: error: hp50.o: No such file or directory 
gcc: error: hp400.o: No such file or directory 
gcc: error: hp_wsp.o: No such file or directory 
gcc: error: int_lpc.o: No such file or directory 
gcc: error: isfextrp.o: No such file or directory 
gcc: error: isp_az.o: No such file or directory 
gcc: error: isp_isf.o: No such file or directory 
gcc: error: lagconc.o: No such file or directory 
gcc: error: lag_wind.o: No such file or directory 
gcc: error: levinson.o: No such file or directory 
gcc: error: lp_dec2.o: No such file or directory 
gcc: error: ph_disp.o: No such file or directory 
gcc: error: pitch_f4.o: No such file or directory 
gcc: error: pit_shrp.o: No such file or directory 
gcc: error: pred_lt4.o: No such file or directory 
gcc: error: preemph.o: No such file or directory 
gcc: error: p_med_ol.o: No such file or directory 
gcc: error: qisf_ns.o: No such file or directory 
gcc: error: qpisf_2s.o: No such file or directory 
gcc: error: q_gain2.o: No such file or directory 
gcc: error: q_pulse.o: No such file or directory 
gcc: error: random.o: No such file or directory 
gcc: error: residu.o: No such file or directory 
gcc: error: scale.o: No such file or directory 
gcc: error: syn_filt.o: No such file or directory 
gcc: error: updt_tar.o: No such file or directory 
gcc: error: util.o: No such file or directory 
gcc: error: voicefac.o: No such file or directory 
gcc: error: wb_vad.o: No such file or directory 
gcc: error: weight_a.o: No such file or directory 
gcc: error: homing.o: No such file or directory 
make: *** [coder] Error 1 
+3

有什么实际* *错误?在Makefile中我没有看到任何对文字“filename”的引用。 – 2015-02-09 20:42:37

+0

隐式规则中的'$ dmedine 2015-02-09 20:46:31

+0

我更新了这个问题,我得到了 – nprak 2015-02-09 20:48:40

编译器不找对象文件,因为它们不建。并且目标文件不会生成,因为源文件位于不同的目录中(例如src),或者由于某些其他原因make不会看到它们。


我调查了这多一点与--debug

make --debug=v -f makefile.gcc 

,并得到

Reading makefiles...
Reading makefile `makefile.gcc'...
Updating goal targets....
Considering target file `all'.
File `all' does not exist.
Considering target file `coder'.
File `coder' does not exist.
Considering target file `coder.o'.
File `coder.o' does not exist.
Considering target file `typedef.h'.
Finished prerequisites of target file `typedef.h'.
No need to remake target `typedef.h'.
Considering target file `basic_op.h'.
Finished prerequisites of target file `basic_op.h'.
No need to remake target `basic_op.h'.
...
Considering target file `count.h'.
Finished prerequisites of target file `count.h'.
No need to remake target `count.h'.
Pruning file `cod_main_fx.h'.
Finished prerequisites of target file `coder.o'.
Must remake target `coder.o'.
Successfully remade target file `coder.o'.
Considering target file `agc2.o'.
File `agc2.o' does not exist.
Pruning file `cnst_fx.h'.
Pruning file `acelp_fx.h'.
Pruning file `typedef.h'.
Pruning file `basic_op.h'.
...
Finished prerequisites of target file `homing.o'.
Must remake target `homing.o'.
Successfully remade target file `homing.o'.
Finished prerequisites of target file `coder'.
Must remake target `coder'.
gcc -Wall -g -O4 -DWMOPS=0 -D__MSDOS__ -o coder coder.o agc2.o autocorr.o ...
gcc: error: coder.o: No such file or directory
gcc: error: agc2.o: No such file or directory
gcc: error: autocorr.o: No such file or directory

因为头文件的依赖性,使得公司认为他们已经正确地重拍的对象文件的目标,甚至尽管它没有看到源文件。

如果提供的源文件(即使是空的),输出看起来不同的一点

...
Finished prerequisites of target file `coder.o'.
Must remake target `coder.o'.
gcc -Wall -g -O4 -DWMOPS=0 -D__MSDOS__ -c coder.c
Successfully remade target file `coder.o'.
Considering target file `agc2.o'.
File `agc2.o' does not exist.
Pruning file `cnst_fx.h'.
...

在这里你可以看到,如何让检查所有先决条件,然后重建对象文件,使用在makefile中给出的隐式规则。

您可以通过将源文件明确列为依赖项来避免混淆,例如,然后

coder.o: coder.c 

make会抱怨缺少的源文件,而无需调用链接命令

make: *** No rule to make target `coder.c', needed by `coder.o'. Stop.

+0

我不明白这可能是真的。目标文件根据此makefile作为目标的先决条件列出;因此,如果make不能找到它们或者构建它们,它会报告错误,它不会尝试构建目标。 – MadScientist 2015-02-09 22:49:12

+0

只需亲自尝试一下。用makefile和需要的头文件创建一个目录并运行make。你会看到完全的OP(gcc's)错误信息。 – 2015-02-10 07:20:00

+0

我也调试过它似乎有问题的C文件是不能够使目标文件。感谢您的时间和帮助。 – nprak 2015-02-10 14:45:33