nvcc -cuda with cutil functions

I got a file a.cu compile with -cuda

The file a.cu contains calls to cutil functions

I’m doing this because I need to call the cuda functions from other C files

nvcc -cuda -I $(SDK)/common/inc a.cu

and then compiled with gcc

gcc -o a.cu.o -I $(SDK)/common/inc -L $(CUDA)/lib -lcudart -L $(SDK)/lib -lcutil a.cu.c

everything looks fine to me, but it doesn’t work with error messages “undefined reference” to those cutil functions. While I’ve already compiled them with the links to the libraries.

I couldn’t understand why can’t the compiler find the cutil functions. Does any see any problems with the way i compile? I’m using Fedora Core 8.

Does this mean the cutil functions cannot be compiled with gcc?

gcc cares about the order of libraries/source code. try

gcc a.cu.c -o a.cu.o -I $(SDK)/common/inc -L $(CUDA)/lib -lcudart -L $(SDK)/lib -lcutil

The order you list libraries can also be important if one library makes calls to another. A useful linker option to know about is --start-group -lthis -lthat --end-group. Check your ld man page for more info.