Linking against the driver API Appropriate library under Linux

Hi,
when compiling my CUDA Program I get the linker errors like "undefined reference to ‘cuCtxCreate’ ". Under Windows linking against cuda.lib is sufficient (e.g. nvcc -I … xyz.cu -o 123.exe cuda.lib ). Under Linux none of the cuda libraries nor -lcudart do work.
What is the mistake? Can you help me?

Navier

first of all there is a linux section in this forum.

and the compiler output could be usefull

you should link with -lcuda or -lcudart

this means link with the library libcuda.so or libcudart.so

this is the standard way to link with gcc.

if you want to a give a librarypath to the compiler use -L

but if you have installed the toolkit the path should be set.

by the way the ending .exe isn`t necessary in linux

Thank you for your fast reply!

Sorry!

The appropriate path and the option -lcudart is set in nvcc.profile. Indeed the linker does actually find the LIBs. But it doesn’t patch the undefined references. What is the right sequence for specifying sources and objects?

Let’s say A.cu depends on B.so and B.so depends on C.so . What is the right order? nvcc A.cu -lB -lC ? Or nvcc -lC -lB A.cu ? Or something else?

Of course, you’re right.

you want to use -lcuda; -lcudart does not imply -lcuda.

-lB -lC

should be right (at least for gcc it is)

but i never linked with nvcc.

I always used nvcc to compile my cu files gcc for the cpp and then i linked

everything together with gcc. (all of this by using a makefile)

and it works.

Thanx to all!

-lcuda solved my problem.

Navier