2016-06-21 9 views
1

私はこのMakefileを持っている:なぜこの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) 

をし、フォルダは次のようになります。

enter image description here

をしかし、私は取得しています:

[email protected]:/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. 

これは私の古いプロジェクトでありますそれはうまくいっているはずでしたが、これを修正する方法は?

+0

、どのディレクトリに?ところで、私は別のディレクトリにオブジェクトファイルを置くことは、特に小さなプロジェクトのための悪い習慣であると信じています... –

+0

ああ、ええ@BasileStarynkevitchは、トリックを行う必要があります!うーん、あなたはそれらについて何をお勧めしますか? – gsamaras

+1

@BasileStarynkevitchオブジェクトファイルを別々のディレクトリに置かないと、デバッグ/リリースオブジェクトファイルが混ざり合ってデバッグに時間が掛かります。オブジェクトファイルを別々のディレクトリに置くことがベストプラクティスです。 –

答えて

5

mainディレクトリは同じレベルにありますが、makefilesディレクトリから呼び出すとします。 main/main_exp_par_auto.cppを探して見つけられません。

呼び出しようなmake:あなたは `make`コマンドを実行している

make -C /media/gsamaras/a6cd1464-abf1-4a7b-b4a2-61f584d4cb32/gsamaras/code/C++/kd_GeRaF-master -f makefiles/Makefile_exp_par_auto 
関連する問題