The project mainly composed of a.cu, b.cu,common.cu and CMakeLists.txt. If
code set(CMAKE_CUDA_FLAGS "-rdc=true -dlink") is commented out, Link always report error: __cudaRegisterLinkedBinary_348e6aeb_4_a_cu_ab145366. If code set(CMAKE_CUDA_FLAGS "-rdc=true -dlink") is not commented out, Compile always report error: ptxas fatal : Unresolved extern function '_Z12common_helloi'.
How to share common device method common_hello between a.cu and b.cu?
I’m not sure why you are using extern "C". It shouldn’t be necessary for what you have shown here, and it is causing you trouble. The fact that linker is having trouble with '_Z12common_helloi' indicates it is looking for a usable device function with C++ style linkage, named common_hello(). But the only definition of common_hello() you have given is one that declares itself using C style linkage; the definition is preceded by extern "C".
If it were me, I would start by getting rid of every instance of extern "C" in your project.
If you’re having trouble compiling the things in the yml directory, my guess is that you are having a problem with CMake. I won’t be able to help with that, although others may. CMake is not a NVIDIA product.