Link new library CUDA error:undefined reference to `__cudaRegisterLinkedBinary`

Hello! I am struggling with a CMAKE. I have 2 files: a.cpp and a.cu. I want to use a function from a.cu in a.cpp. So, I developed this CMAKE:

cuda_add_library(R a.cu)
target_link_libraries(R <other_libraries>)

add_executable(R2 a.cpp)
target_link_libraries(R2 R)

When I build this. I have 2 errors, both with __cudaRegisterLinkedBinary. I tried to debug it for one day, but I failed. My CUDA_FLAGS are: “-rdc=true -lcudadevrt -lcudart”. Thank you!!

P.S.: when I comment the last 2 lines, everything is ok (the library is built)

1 Like