c++ - Makefile leads to compilation error -


i'm trying compile program (which isn't mine):

make -f makefile 

... using following makefile:

# compiler .cpp files cpp  = g++  # use nvcc compile .cu files nvcc = nvcc nvccflags = -arch sm_20 # fermi's in keeneland  # add cuda paths icuda = /usr/lib/nvidia-cuda-toolkit/include lcuda = /usr/lib/nvidia-cuda-toolkit/lib64  # add cuda libraries link line lflags += -lcuda -lcudart -l$(lcuda) -lgomp  # include standard optimization flags cppflags = -o3 -c -i $(icuda) -xcompiler -fopenmp -dthrust_device_backend=thrust_device_backend_omp  # list of objects need objects  = timer.o ar1.o kgrid.o vfinit.o parameters.o  # rule tells make how make program objects main :  main.o $(objects)         $(cpp) -o main main.o $(objects) $(lflags)  # rule tells make how turn .cu file .o %.o: %.cu                 $(nvcc) ${nvccflags} $(cppflags) -c $<  # how make know how turn .cpp .o?  it's built-in! # if wanted type out like: # %.o: %.cpp #       $(cpp) $(cppflags) -c $<  clean :         rm -f *.o         rm -f core core.*  veryclean :         rm -f *.o         rm -f core core.*         rm -f main 

which results in following commands:

nvcc -arch sm_20  -o3 -c -i /usr/lib/nvidia-cuda-toolkit/include -xcompiler -fopenmp -dthrust_device_backend=thrust_device_backend_omp -c main.cu g++  -o3 -c -i /usr/lib/nvidia-cuda-toolkit/include -xcompiler -fopenmp -dthrust_device_backend=thrust_device_backend_omp  -c -o timer.o timer.cpp g++: error: unrecognized command line option â-xcompilerâ make: *** [timer.o] error 1 

i don't understand makefile: -xcompiler flag (in variable cppflags) should used nvcc compiler, not g++. therefore, understand why getting error. however, don't understand, basic understanding of makefile above, why @ point variable cppflags follows g++ (variable cpp). don't see such sequence in makefile.

your main rule requires timer.o. there no explicit rule timer.o make uses built in implicit rule (as mentioned in comment @ end of makefile). implicit rule converting .cpp files .o files has form

$(cpp) $(cppflags) -c $< 

so it's compiling using options in cppflags contains -xcompiler. want -xcompiler flag in nvccflags , not cppflags.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -