Reputation: 1446
I am trying to use the following in a makefile, but when I type make filter_test
it gives me the error below, and I can not figure out why. Note the spaces where the input files should be.
CXX=g++
CXXFLAGS=-O1 -pedantic -Wall -Werror -g
DEPS=p2.o recursive.o [email protected]
p2.o: p2.cpp ; $(CXXFLAGS) -c p2.cpp
recursive.o: recursive.cpp ; $(CXXFLAGS) -c recursive.cpp
filter_test: p2.o [email protected] recursive.o ; $(CXX) $(CXXFLAGS) recursive.o p2.o [email protected] -o aaa
Output:
g++ -O1 -pedantic -Wall -Werror -g -o .cpp
g++: fatal error: no input files
compilation terminated.
make: *** [.cpp] Error 4
Upvotes: 0
Views: 166
Reputation: 212178
$@
only has a value inside the recipe, so when make
sees $@
in the prerequisite list, it treats it as an empty string. So make is trying to build the pre-requisite .cpp
and using the default rule to build it. To fix this just write:
filter_test: p2.o filter_test.cpp recursive.o
Leave the recipe blank and let make use default rules.
Upvotes: 1