c++ - makefile can't find .o file -
i'm working on simple makefile using implicit rules, , not understanding how make deciding execution order. when have makefile setup this, says can't find wave.o:
cxx = g++ audiosample: wave.o audiosample.o $(cxx) -o audiosample audiosample.o wave.o audiosample.o: wave.h pcadpcm.h $(cxx) -c audiosample.cpp wave.o: wave.h
terminal output:
g++ -o audiosample audiosample.o wave.o g++: error: wave.o: no such file or directory make: *** [audiosample] error 1
however when change order of targets works fine:
audiosample: wave.o audiosample.o $(cxx) -o audiosample audiosample.o wave.o wave.o: wave.h audiosample.o: wave.h pcadpcm.h $(cxx) -c audiosample.cpp
terminal output:
g++ -c -o wave.o wave.cpp g++ -c audiosample.cpp g++ -o audiosample audiosample.o wave.o
whats problem??
double-check tabs vs spaces in makefile
.
for example vim editor, can search tabs /\t
or add following config:
" in ~/.vimrc listchars=tab:»»,trail:·,nbsp:~ set list
you have hidden tab in wave.o
rule (shown in editor):
wave.o : wave.h »»»»»»
this tab breaks implicit rules generate wave.o
. remove tabs , fine second makefile
there no room tab target last line of file.
for information, wave.h
prerequisite , not used make
guess source file name (wave.cpp
in case). wave.o : wave.cpp
wouldn't have helped.
Comments
Post a Comment