CUDA compilation on Linux (Makefiles)
I have been struggling with compiling complex CUDA code, with complex I mean a lot of .cu .F .cpp and .c files. I have created a makefile that can help you compile that kind of code. I'll try to give a quick view of it here explaining some parts: First you'll need to specify the CUDA path and the compilers and linkers. Here I am using gcc and g++ for .c and .cpp files and nvcc for .cu files: CUDA_INSTALL_PATH ?= /usr/local/cuda CXX := g++ CC := gcc LINK := g++ -fPIC NVCC := nvcc -ccbin /usr/bin Then you need to specify where to locate the CUDA header files : # Includes INCLUDES = -I. -I$(CUDA_INSTALL_PATH)/include # Common flags COMMONFLAGS += $(INCLUDES) NVCCFLAGS += $(COMMONFLAGS) CXXFLAGS += $(COMMONFLAGS) CFLAGS += $(COMMONFLAGS) Then you specify where to locate the CUDA binaries for linking : LIB_CUDA := -L$(CUDA_INSTALL_PATH)/lib -lcudart Then you specify the object files that the executable depends on and the name of the executable flle:...