Search code examples
makefilecompiler-constructionyacc

Writing a MakeFile for a C compiler, getting a "no input files" fatal error


my MakeFile is like this: (this creates a main program that takes a file and produces syntax trees, TAC code etc. Classes used in main.cpp and the parser.y are defined in classes.cpp)

MAIN = main
PARSE = parser
SCAN = scanner
CLASS = classes

compiler: lex.yy.c y.yab.h y.tab.c $(CLASSES).cpp
     g++ -std=c++11 -Wno-write-strings -o compiler $(MAIN).cpp

y.tab.c y.tab.h: $(PARSE).y $(CLASSES).cpp
     yacc -d $(PARSE).y

lex.yy.c: $(SCAN).l
     lex $(SCAN).l

clean:
     rm -f lex.yy.* y.tab.* *.tokens *.syntree *.tac *.log compiler

but when I run make I get

g++          -o .cpp
g++: fatal error: no input files
compilation terminated.
<builtin>: recipe for target '.cpp' failed
make: *** [.cpp] Error 1

how do I resolve this?


Solution

  • “error: no input files” means src files were not exist. Common reason is you move or remove some src file.