When I try to compile my CUDA program, I get the following errors:
b.o: In function `mul_wrapper':
/tmp/tmpxft_00002a64_00000000-13_b.ii:(.text+0xcb): undefined reference to `cudaConfigureCall'
/tmp/tmpxft_00002a64_00000000-13_b.ii:(.text+0xe7): undefined reference to `cudaDeviceSynchronize'
/tmp/tmpxft_00002a64_00000000-13_b.ii:(.text+0x144): undefined reference to `cudaFree'
b.o: In function `cudaError cudaMallocManaged<float>(float**, unsigned long, unsigned int)':
/tmp/tmpxft_00002a64_00000000-13_b.ii:(.text+0x18a): undefined reference to `cudaMallocManaged'
b.o: In function `__device_stub__Z3mulPf(float*)':
/tmp/tmpxft_00002a64_00000000-13_b.ii:(.text+0x1df): undefined reference to `cudaSetupArgument'
b.o: In function `cudaError cudaLaunch<char>(char*)':
/tmp/tmpxft_00002a64_00000000-13_b.ii:(.text+0x221): undefined reference to `cudaLaunch'
b.o: In function `__sti____cudaRegisterAll_36_tmpxft_00002a64_00000000_7_b_cpp1_ii__Z3mulPf()':
/tmp/tmpxft_00002a64_00000000-13_b.ii:(.text+0x243): undefined reference to `__cudaRegisterFatBinary'
b.o: In function `__nv_cudaEntityRegisterCallback(void**)':
/tmp/tmpxft_00002a64_00000000-13_b.ii:(.text+0x2f2): undefined reference to `__cudaRegisterFunction'
b.o: In function `__cudaUnregisterBinaryUtil()':
/tmp/tmpxft_00002a64_00000000-13_b.ii:(.text+0x31b): undefined reference to `__cudaUnregisterFatBinary'
collect2: error: ld returned 1 exit status
Makefile:3: recipe for target 'run' failed
make: *** [run] Error 1
My make file looks like this:
run: main.o b.o
gcc -fPIC -L /usr/local/cuda/lib -lcudart -o run main.o b.o
main.o: main.c b.h
gcc -fPIC -I /usr/local/cuda/include -c -o main.o main.c
b.o: b.cu b.h
nvcc -Xcompiler -fPIC -ccbin clang-3.8 -c -o b.o b.cu
It seems like the problem has to do with the files "/usr/local/cuda/include" and "/usr/local/cuda/lib" not being found on my system. I am using Ubuntu 17.04 and have installed the CUDA toolkit with apt. I heard that installing CUDA toolkit with apt doesn't create the /usr/local/cuda/* files, so I tried to install it from the run file, but that faild to install.
UPDATE: I reinstalled CUDA toolkit and now I have the /usr/local/cuda/* directory, but the problem still persists.