Help~~ Compilation problem about MPI+CUDA

My Program List:
2dcspresdm.rtm.random.iso.c
2dcspresdm.rtm.random.iso.cu

My Makefile:
INC= -I/data/users/tools/mpich/include -I/usr/local/NVIDIA_CUDA_SDK/common/inc -I/usr/local/cuda/include
MPI_LIB = /data/users/tools/mpich/lib -L/usr/local/NVIDIA_CUDA_SDK/lib
MODULE = 2dcspresdm.rtm.random.iso
EXECS= (BIN)/(MODULE).e
(EXECS): (MODULE).o (MODULE).co mpicc (MODULE).o (MODULE).co -lm -L(MPI_LIB) -o (EXECS) (MODULE).o:(MODULE).c mpicc -c (MODULE).c (INC) -o (MODULE).o
(MODULE).co:(MODULE).cu
nvcc -c (MODULE).cu (INC) -o $(MODULE).co

When I type “make” in the terminal, the mpicc compiler says:

nvcc -c 2dcspresdm.rtm.random.iso.cu -I/data/users/tools/mpich/include -I/usr/local/NVIDIA_CUDA_SDK/common/inc -I/usr/local/cuda/include -o 2dcspresdm.rtm.random.iso.co
mpicc 2dcspresdm.rtm.random.iso.o 2dcspresdm.rtm.random.iso.co -lm -L/data/users/tools/mpich/lib -L/usr/local/NVIDIA_CUDA_SDK/lib -o ./data_result/2dcspresdm.rtm.random.iso.e
2dcspresdm.rtm.random.iso.o: In function presdm': 2dcspresdm.rtm.random.iso.c:(.text+0x8d8): undefined reference to cudaMalloc’
2dcspresdm.rtm.random.iso.c:(.text+0x8ec): undefined reference to `cudaMalloc’

If we use nvcc compiler, it will link the function library automatically. But it doesnot recognize MPI function. When we use mpicc, the “cudaMalloc()” is undefined. Please help me to compile my program or tell me which library I should link. Thanks a lot~~ :teehee:

You need to provide the library names of all of the libraries you are trying to link against, so at least libcudart and libmpi, plus anything else they might need.

Yeah, I think you’re right. But I cann’t find the static library file “libcudart.a” or “libmpi.a” in the path (CUDA_INSTALL_PATH)/lib and (CUDA_SDK_PATH)/lib. And also i’ve tried “find -name libcudart.a”, still doesn’t work. Why I don’t have these libraries? Does it mean my CUDA installation is incorrect? ^~^

Cuda isn’t supplied with static libraries, only shared versions of libcuda and libcudart are included in the driver package and toolkit.

Ah~ I get it. So sorry for such a funny mistake~~ I found those dynamic libraries and problem solved! I really appreciate your support~~

eh… another thing, the compiler says “identifier “CUTBoolean” is undefined”, it is in my header file “cutil.h”. But this time i don’t need that. My program only needs “cuda_runtime.h”. But I still can’t figure out why that standart header file includes undefination?