Skip to content

Unresolved external symbol __cudaRegisterLinkedBinary when building as a static library #181

@StonerLing

Description

@StonerLing

Description: When PopSift is integrated into another project via add_subdirectory() and built as a static library (BUILD_SHARED_LIBS=OFF), the linker fails with the following errors:

popsift.lib(sift_conf.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_... referenced in function "void __cdecl __sti____cudaRegisterAll(void)"
popsift.lib(popsift.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_... referenced in function "void __cdecl __sti____cudaRegisterAll(void)"
...

Cause: The root cause seems to be the hardcoded set(CMAKE_CUDA_SEPARABLE_COMPILATION ON) in the main CMakeLists.txt (line 114).

When RDC (Relocatable Device Code) is enabled for a static library, the host project (the executable) is responsible for the final device linking stage. However, most host projects do not enable RDC by default, leading to these unresolved symbols.

Environment:

  • OS: Windows 10
  • Compiler: MSVC 14.38.33130
  • CUDA: 11.3.58
  • CMake: 3.31.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    cudaissues related to cuda versionsscope:build

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions