'cannot find -lcudart' - Yep another one! Having a hard time compiling my project on Ubu

Hey guys,

I’m adding to a litle project of mine, fiddling with CUDA. I’m getting along with the coding side of things, but compiling and linking is causing me grief. My makefile is as follows:

CC=gcc

NVCC=nvcc

CFLAGS=-lm -Wall -lpng -lz -fopenmp -lcudart -O3

OFLAGS=-o fractal

MFLAGS=-c

all: fractal

fractal: main.o arguments.o instance.o mandelbrot.o newton.o complex_type.o

	$(CC) $(CFLAGS) $(OFLAGS) main.o arguments.o instance.o mandelbrot.o newton.o complex_type.o

main.o: main.c 

	$(CC) $(CFLAGS) $(MFLAGS) main.c

arguments.o: arguments.c

	$(CC) $(CFLAGS) $(MFLAGS) arguments.c

instance.o: instance.c

	$(CC) $(CFLAGS) $(MFLAGS) instance.c

mandelbrot.o: mandelbrot.cu

	$(NVCC) $(MFLAGS) mandelbrot.cu

newton.o: newton.c

	$(CC) $(CFLAGS) $(MFLAGS) newton.c

complex_type.o: complex_type.c

	$(CC) $(CFLAGS) $(MFLAGS) complex_type.c

And, sure enough, the compiler gives me:

/usr/bin/ld: cannot find -lcudart

…which is a pretty common problem, apparently. I’ve tried various solutions, I’m not using -static, I’ve tried adding various paths to various config files, no luck. Any suggestion is welcome at this point, even if you think I’ve tried it, please suggest it: if only so we can check things off the list.

Aha!

Okay, feeing a little dumb right now. I changed my CFLAGS to:

CFLAGS=-lm -Wall -lpng -lz -lcuda -lcudart -fopenmp -O3 -L/usr/local/cuda/lib

And everything went fine. I thought this problem had been checked, it seems not. As always, it pays to try, try again. Hopefully someone will learn from my silly mistake.