Undefined reference error __device_builtin_variable_blockIdx

I compile my .cu and .cpp file to a libcuda.so file. Then i compile my main.cpp as a executable file and target_link_libraries libcuda.so . This is an error occure libcuda.so : undefined reference to `__device_builtin_variable_blockIdx’

thank you for your reply!

libcuda.so is a library name used by CUDA.

Choose another name for your library.

thank you for your reply ! I change my .so filename, the error is libpatch_cuda.so : undefined reference to `__device_builtin_variable_blockIdx’ It is the same error occure.

Depending on whether you are using the driver API or the runtime API, you will need to link against either libcuda.so or libcudart.so

This is evidently a question about cmake usage, I won’t be able to help much there.