Hello! I am writing a small project, but the number of libraries and other flags when compiling makes you look in the direction of the make . I have such a compilation string

 nvcc -I/usr/local/include/opencv -I/usr/lib/mpich2/include/ -g -L/usr/local/lib -L/usr/lib -o main main.cu -lopencv_core -lopencv_imgproc -lopencv_highgui -lmpi -lopa -lmpl -lrt -lcr -lpthread -lboost_filesystem -lboost_system 

I didn’t have a special deal with make files before, but approximately I imagine what it is. In the make file, I need to specify the source folder, the folder with the header files, the folder into which the binary will be assembled, well, and specify the paths used or if they are compiled. How does this makefile look like? And how does make differ from cmake ? What is better to use?

    1 answer 1

    I think the easiest and most primitive option.

     LIBS_PATH = -L/usr/local/lib -L/usr/lib LIBS = -lopencv_imgproc -lopencv_highgui -lmpi -lopa -lmpl -lrt -lcr -lpthread -lboost_filesystem -lboost_system -lopencv_core INCLUDE_PATH = -I/usr/local/include/opencv -I/usr/lib/mpich2/include/ FLAGS = -g -O2 main: main.cu nvcc $(INCLUDE_PATH) $(FLAGS) -o $@ $^ $(LIBS_PATH) $(LIBS) 
    • Fine! What I need, just to specify the directory with the samples and the directory for the binary, would be super! Probably at your leisure you should read more about these make files, in some situations a very handy thing. - Re1aps
    • I also advise you to look at tup as an alternative to make . - VioLet