我有这个Makefile:
OBJS = main_exp_par_auto.o
SOURCE = ../main/main_exp_par_auto.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 ../Auto_random_kd_forest.h
OUT = geraf
CXX = g++
FLAGS = -pthread -std=c++0x -DRKD_PAR -O3 -Wall
all: $(OBJS)
$(CXX) $(OBJS) -o $(OUT) $(FLAGS)
make -f makefiles/Makefile_exp_par_auto clean
# create/compile the individual files >>separately<<
main_exp_par_auto.o: main/main_exp_par_auto.cpp
$(CXX) -c main/main_exp_par_auto.cpp $(FLAGS)
.PHONY : all
# clean house
clean:
rm -f $(OBJS)
# do a bit of accounting
count:
wc $(SOURCE) $(HEADER)
Run Code Online (Sandbox Code Playgroud)
和文件夹看起来像这样:
但是,我得到了:
gsamaras@gsamaras-A15:/media/gsamaras/a6cd1464-abf1-4a7b-b4a2-61f584d4cb32/gsamaras/code/C++/kd_GeRaF-master/makefiles$ make -f Makefile_exp_par_auto
make: *** No rule to make target `main/main_exp_par_auto.cpp', needed by `main_exp_par_auto.o'. Stop.
Run Code Online (Sandbox Code Playgroud)
这是我的一个旧项目,应该是有效的,如何解决这个问题?
您是从makefiles目录调用它,而main目录是在同一级别.它寻找main/main_exp_par_auto.cpp并找不到它.
这样调用make:
make -C /media/gsamaras/a6cd1464-abf1-4a7b-b4a2-61f584d4cb32/gsamaras/code/C++/kd_GeRaF-master -f makefiles/Makefile_exp_par_auto
Run Code Online (Sandbox Code Playgroud)