0
votes

My Makefile was fine. However, now I want to have a folder named "Makefile" and a folder named "main", where the first will contain my Makefiles and the second will contain files that are meant to be the main() of my my project, k-d GeRaF.

For now, the header files lie in the same folder. That folder also contains Makefile folder and main folder.

Here is my makefile (have tried many combinations, this is the last attempt):

OBJS    = main_par_auto.o
SOURCE  = ../main/main_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)

# create/compile the individual files >>separately<< 
main_par_auto.o:    main_par_auto.cpp
    $(CXX) -c   ../main/main_par_auto.cpp   $(FLAGS)

.PHONY : all
# clean house
clean:
    rm -f $(OBJS)

and I am getting this error:

make: *** No rule to make target `main_par_auto.cpp', needed by `main_par_auto.o'.  Stop.

I am executing this command: make -f Makefile/Makefile_par_auto in order to compile.

What am I missing please?

This is the big picture ( literally :) ) enter image description here

1
Have you tried main_par_auto.o: ../main/main_par_auto.cpp?jadhachem
Yes @jadhachem. make: *** No rule to make target `../main/main_par_auto.cpp`, needed by main_par_auto.o'. Stop.`gsamaras
Are the paths relative to the working directory or to the path of the makefile?Wintermute
@Wintermute I am not sure what you asked. I made a screenshot, did this help? I think the first. I am running make from the folder that appears in the screenshot.gsamaras

1 Answers

1
votes

The paths in the Makefile have to be relative to the working directory (the directory from which you run make), not to the directory that contains the Makefile. With

main_par_auto.o: main/main_par_auto.cpp
    $(CXX) -c main/main_par_auto.cpp $(FLAGS)

you should get the expected results.

Note that it is very unusual to expect a user to invoke make this way. Normally, you'd expect to have a Makefile in the directory where you call make (that may or may not go on to use other makefiles in other directories).