I have many makefiles under the same project directory.
The Makefile_prune:
OBJS = main.o
SOURCE = main.cpp
HEADER = Division_Euclidean_space.h Find_diameter.h Find_k_max.h Householder.h IO.h Mean_variance.h Point.h Random_generator.h Random_kd_forest.h Tree.h
OUT = rkd
CC = g++
FLAGS = -std=c++0x -O3 -c -Wall
# -c flag generates object code for separate files
all: $(OBJS)
$(CC) $(OBJS) -o $(OUT)
make clean
# create/compile the individual files >>separately<<
main.o: main.cpp
$(CC) $(FLAGS) main.cpp
.PHONY : all
# clean house
clean:
rm -f $(OBJS)
# do a bit of accounting
count:
wc $(SOURCE) $(HEADER)
I am getting the error for clean, as you can see below:
samaras@samaras-A15:~/code$ make -f Makefile_prune
g++ -std=c++0x -O3 -c -Wall main.cpp
g++ main.o -o rkd
make clean
make[1]: Entering directory `/home/samaras/paper/rkd_forest/code'
make[1]: *** No rule to make target `clean'. Stop.
make[1]: Leaving directory `/home/samaras/paper/rkd_forest/code'
make: *** [all] Error 2
Then I can run make -f Makefile_prune clean
, which will execute the clean-up, but I want to be single commanded, I mean, not having to press enter twice.
Related answers:
- “make clean” results in “No rule to make target `clean'”
- gcc makefile error: “No rule to make target …”
Idea:
The makefile actually was used for a C project I had and I just made some changes to fit the C++, maybe this is the problem.