CMake Linking Issues

Hello,

I am working on an Orin NX 8GB Jetson and I have an issue within CMake getting the cudnn library to link properly. What I do have working so far is an nvcc command in the terminal properly compiling and linking the same main.cu file.

The working nvcc invoked at the command line is:

nvcc main.cu -L.. -L/usr/local/cuda-12.6/lib64 -I/usr/local/cuda-12.6/include/ -I.. -lLoadSafeLandingNetwork -lcudnn -lcublas

This yields the default executable “a.out” and I get the output I expect when I run it.

Now, if I move this into a CMakeLists.txt that should be operating identically (so I think…), I get linking errors on various functions:

  • __sti____cudaRegisterAll()
  • cublasCreate_v2()
  • cudnnDestroy()
  • etc…

The CMakeLists.txt I’ve created to replicate the command line nvcc invoke is:

project ("CMakeCUDA_Test" )
include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
    enable_language(CUDA)
    if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
      set(CMAKE_CUDA_ARCHITECTURES 75)
    endif()
    find_package(CUDAToolkit)
    message(STATUS "Enabled CUDA Compiler")
    message(STATUS "${CUDAToolkit_BIN_DIR}")
    message(STATUS "${CUDAToolkit_INCLUDE_DIRS}")
    message(STATUS "${CUDAToolkit_LIBRARY_DIR}")
else()
    message(STATUS "No CUDA Compiler found")
endif()

# Add source to this project's executable.
file(GLOB test_SRC "main.cu")

add_executable (cmake_test ${test_SRC})

# Add libraries
target_link_directories(cmake_test PUBLIC ".." ${CUDAToolkit_LIBRARY_DIRS})
target_include_directories(cmake_test PUBLIC ".." ${CUDAToolkit_INCLUDE_DIRS})
target_link_libraries(cmake_test -lcudnn -lcublas "libLoadSafeLandingNetwork.a")

Which yield the output when CMake runs:

jetson@ubuntu:~/Documents/safe_landing/LoadSafeLandingNetwork/examples/build$ cmake ../
-- Enabled CUDA Compiler
-- /usr/local/cuda-12.6/bin
-- /usr/local/cuda-12.6/targets/aarch64-linux/include
-- /usr/local/cuda-12.6/lib64
-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/build

And after generating the Makefile and running a simple make command in the CMake build folder I get the following output:

jetson@ubuntu:~/Documents/safe_landing/LoadSafeLandingNetwork/examples/build$ make clean
jetson@ubuntu:~/Documents/safe_landing/LoadSafeLandingNetwork/examples/build$ make
[ 50%] Building CUDA object CMakeFiles/cmake_test.dir/main.cu.o
[100%] Linking CUDA executable cmake_test
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(LoadSafeLandingNetwork_initialize.o): in function `__sti____cudaRegisterAll()':
tmpxft_00011a78_00000000-6_LoadSafeLandingNetwork_initialize.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_7a267d6e_36_LoadSafeLandingNetwork_initialize_cu_2898256c'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(LoadSafeLandingNetwork_terminate.o): in function `__sti____cudaRegisterAll()':
tmpxft_00011a95_00000000-6_LoadSafeLandingNetwork_terminate.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_3ae6c24e_35_LoadSafeLandingNetwork_terminate_cu_1fc783d4'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(LoadSafeLandingNetwork.o): in function `__sti____cudaRegisterAll()':
tmpxft_00011a9d_00000000-6_LoadSafeLandingNetwork.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_22b20966_25_LoadSafeLandingNetwork_cu_dedc86e0'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(DeepLearningNetwork.o): in function `__sti____cudaRegisterAll()':
tmpxft_00011aae_00000000-6_DeepLearningNetwork.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_07338302_22_DeepLearningNetwork_cu_3c015049'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(predict.o): in function `__sti____cudaRegisterAll()':
tmpxft_00011ad3_00000000-6_predict.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_75a86cda_10_predict_cu_422f9cd0'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(LoadSafeLandingNetwork_rtwutil.o): in function `__sti____cudaRegisterAll()':
tmpxft_00011ae6_00000000-6_LoadSafeLandingNetwork_rtwutil.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_db4e2d52_33_LoadSafeLandingNetwork_rtwutil_cu_3c1e1de5'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnTargetNetworkImpl.o): in function `MWCudnnTarget::MWTargetNetworkImpl::preSetup()':
tmpxft_00011a16_00000000-6_MWCudnnTargetNetworkImpl.cudafe1.cpp:(.text+0x38): undefined reference to `cublasCreate_v2'
/usr/bin/ld: tmpxft_00011a16_00000000-6_MWCudnnTargetNetworkImpl.cudafe1.cpp:(.text+0x58): undefined reference to `cudnnCreate'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnTargetNetworkImpl.o): in function `MWCudnnTarget::MWTargetNetworkImpl::cleanup()':
tmpxft_00011a16_00000000-6_MWCudnnTargetNetworkImpl.cudafe1.cpp:(.text+0x240): undefined reference to `cublasDestroy_v2'
/usr/bin/ld: tmpxft_00011a16_00000000-6_MWCudnnTargetNetworkImpl.cudafe1.cpp:(.text+0x268): undefined reference to `cudnnDestroy'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnTargetNetworkImpl.o): in function `__sti____cudaRegisterAll()':
tmpxft_00011a16_00000000-6_MWCudnnTargetNetworkImpl.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_63a1e784_27_MWCudnnTargetNetworkImpl_cu_bac7e8e1'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnLayerImplFactory.o): in function `__sti____cudaRegisterAll()':
tmpxft_00011a20_00000000-6_MWCudnnLayerImplFactory.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_2f799d18_26_MWCudnnLayerImplFactory_cu_66102730'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnCustomLayerBase.o): in function `MWCudnnCustomLayerBase::reorderOutputData(MWTensorBase*, int)':
tmpxft_00011a49_00000000-6_MWCudnnCustomLayerBase.cudafe1.cpp:(.text+0x598): undefined reference to `cudnnTransformTensor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnCustomLayerBase.o): in function `MWCudnnCustomLayerBase::reorderInputData(MWTensorBase*, int)':
tmpxft_00011a49_00000000-6_MWCudnnCustomLayerBase.cudafe1.cpp:(.text+0x758): undefined reference to `cudnnTransformTensor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnCustomLayerBase.o): in function `MWCudnnCustomLayerBase::createInOutDescriptors(MWTensorBase*)':
tmpxft_00011a49_00000000-6_MWCudnnCustomLayerBase.cudafe1.cpp:(.text+0x928): undefined reference to `cudnnCreateTensorDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnCustomLayerBase.o): in function `MWCudnnCustomLayerBase::createInOutTransformDescriptors(MWTensorBase*)':
tmpxft_00011a49_00000000-6_MWCudnnCustomLayerBase.cudafe1.cpp:(.text+0xaf8): undefined reference to `cudnnCreateTensorDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnCustomLayerBase.o): in function `MWCudnnCustomLayerBase::setupInputDescriptors(MWTensorBase*, MWTensorBase::DIMSLABEL*, MWTensorBase::DIMSLABEL*)':
tmpxft_00011a49_00000000-6_MWCudnnCustomLayerBase.cudafe1.cpp:(.text+0xc78): undefined reference to `cudnnSetTensorNdDescriptor'
/usr/bin/ld: tmpxft_00011a49_00000000-6_MWCudnnCustomLayerBase.cudafe1.cpp:(.text+0xd20): undefined reference to `cudnnSetTensorNdDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnCustomLayerBase.o): in function `MWCudnnCustomLayerBase::setupOutputDescriptors(MWTensorBase*, MWTensorBase::DIMSLABEL*, MWTensorBase::DIMSLABEL*)':
tmpxft_00011a49_00000000-6_MWCudnnCustomLayerBase.cudafe1.cpp:(.text+0xea0): undefined reference to `cudnnSetTensorNdDescriptor'
/usr/bin/ld: tmpxft_00011a49_00000000-6_MWCudnnCustomLayerBase.cudafe1.cpp:(.text+0xf48): undefined reference to `cudnnSetTensorNdDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnCustomLayerBase.o): in function `MWCudnnCustomLayerBase::cleanup()':
tmpxft_00011a49_00000000-6_MWCudnnCustomLayerBase.cudafe1.cpp:(.text+0x1028): undefined reference to `cudnnDestroyTensorDescriptor'
/usr/bin/ld: tmpxft_00011a49_00000000-6_MWCudnnCustomLayerBase.cudafe1.cpp:(.text+0x1080): undefined reference to `cudnnDestroyTensorDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnCustomLayerBase.o): in function `__sti____cudaRegisterAll()':
tmpxft_00011a49_00000000-6_MWCudnnCustomLayerBase.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_ced4207d_25_MWCudnnCustomLayerBase_cu_85d82daf'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(LoadSafeLandingNetwork_data.o): in function `__sti____cudaRegisterAll()':
tmpxft_00011a6e_00000000-6_LoadSafeLandingNetwork_data.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_228eb97d_30_LoadSafeLandingNetwork_data_cu_ce61d6df'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnAdditionLayerImpl.o): in function `MWCudnnTarget::MWAdditionLayerImpl::predict()':
tmpxft_00011920_00000000-6_MWCudnnAdditionLayerImpl.cudafe1.cpp:(.text+0x15c): undefined reference to `cudnnAddTensor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnAdditionLayerImpl.o): in function `__sti____cudaRegisterAll()':
tmpxft_00011920_00000000-6_MWCudnnAdditionLayerImpl.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_659ed72b_27_MWCudnnAdditionLayerImpl_cu_59f5bbb7'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnAvgPoolingLayerImpl.o): in function `MWCudnnTarget::MWAvgPoolingLayerImpl::predict()':
tmpxft_00011928_00000000-6_MWCudnnAvgPoolingLayerImpl.cudafe1.cpp:(.text+0x34c): undefined reference to `cudnnPoolingForward'
/usr/bin/ld: tmpxft_00011928_00000000-6_MWCudnnAvgPoolingLayerImpl.cudafe1.cpp:(.text+0x3d4): undefined reference to `cudnnPoolingForward'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnAvgPoolingLayerImpl.o): in function `MWCudnnTarget::MWAvgPoolingLayerImpl::cleanup()':
tmpxft_00011928_00000000-6_MWCudnnAvgPoolingLayerImpl.cudafe1.cpp:(.text+0x480): undefined reference to `cudnnDestroyPoolingDescriptor'
/usr/bin/ld: tmpxft_00011928_00000000-6_MWCudnnAvgPoolingLayerImpl.cudafe1.cpp:(.text+0x4b4): undefined reference to `cudnnDestroyTensorDescriptor'
/usr/bin/ld: tmpxft_00011928_00000000-6_MWCudnnAvgPoolingLayerImpl.cudafe1.cpp:(.text+0x508): undefined reference to `cudnnDestroyTensorDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnAvgPoolingLayerImpl.o): in function `MWCudnnTarget::MWAvgPoolingLayerImpl::propagateSize()':
tmpxft_00011928_00000000-6_MWCudnnAvgPoolingLayerImpl.cudafe1.cpp:(.text+0x600): undefined reference to `cudnnSetPooling2dDescriptor'
/usr/bin/ld: tmpxft_00011928_00000000-6_MWCudnnAvgPoolingLayerImpl.cudafe1.cpp:(.text+0x688): undefined reference to `cudnnSetTensor4dDescriptor'
/usr/bin/ld: tmpxft_00011928_00000000-6_MWCudnnAvgPoolingLayerImpl.cudafe1.cpp:(.text+0x6f8): undefined reference to `cudnnSetTensor4dDescriptor'
/usr/bin/ld: tmpxft_00011928_00000000-6_MWCudnnAvgPoolingLayerImpl.cudafe1.cpp:(.text+0x73c): undefined reference to `cudnnSetTensor4dDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnAvgPoolingLayerImpl.o): in function `MWCudnnTarget::MWAvgPoolingLayerImpl::MWAvgPoolingLayerImpl(MWCNNLayer*, MWCudnnTarget::MWTargetNetworkImpl*, int, int, int, int, int, int, int, int, bool)':
tmpxft_00011928_00000000-6_MWCudnnAvgPoolingLayerImpl.cudafe1.cpp:(.text+0x8f0): undefined reference to `cudnnCreatePoolingDescriptor'
/usr/bin/ld: tmpxft_00011928_00000000-6_MWCudnnAvgPoolingLayerImpl.cudafe1.cpp:(.text+0xa1c): undefined reference to `cudnnCreateTensorDescriptor'
/usr/bin/ld: tmpxft_00011928_00000000-6_MWCudnnAvgPoolingLayerImpl.cudafe1.cpp:(.text+0xacc): undefined reference to `cudnnCreateTensorDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnAvgPoolingLayerImpl.o): in function `__sti____cudaRegisterAll()':
tmpxft_00011928_00000000-6_MWCudnnAvgPoolingLayerImpl.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_ac28b6d6_29_MWCudnnAvgPoolingLayerImpl_cu_9f1d5bd9'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnBatchNormalizationLayerImpl.o): in function `MWCudnnTarget::MWBatchNormalizationLayerImpl::propagateSize()':
tmpxft_00011930_00000000-6_MWCudnnBatchNormalizationLayerImpl.cudafe1.cpp:(.text+0xb4): undefined reference to `cudnnDeriveBNTensorDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnBatchNormalizationLayerImpl.o): in function `MWCudnnTarget::MWBatchNormalizationLayerImpl::predict()':
tmpxft_00011930_00000000-6_MWCudnnBatchNormalizationLayerImpl.cudafe1.cpp:(.text+0x284): undefined reference to `cudnnBatchNormalizationForwardInference'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnBatchNormalizationLayerImpl.o): in function `MWCudnnTarget::MWBatchNormalizationLayerImpl::cleanup()':
tmpxft_00011930_00000000-6_MWCudnnBatchNormalizationLayerImpl.cudafe1.cpp:(.text+0x2f0): undefined reference to `cudnnDestroyTensorDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnBatchNormalizationLayerImpl.o): in function `MWCudnnTarget::MWBatchNormalizationLayerImpl::MWBatchNormalizationLayerImpl(MWCNNLayer*, MWCudnnTarget::MWTargetNetworkImpl*, float, char const*, char const*, char const*, char const*, int)':
tmpxft_00011930_00000000-6_MWCudnnBatchNormalizationLayerImpl.cudafe1.cpp:(.text+0x4bc): undefined reference to `cudnnCreateTensorDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnBatchNormalizationLayerImpl.o): in function `__sti____cudaRegisterAll()':
tmpxft_00011930_00000000-6_MWCudnnBatchNormalizationLayerImpl.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_8d4eff57_37_MWCudnnBatchNormalizationLayerImpl_cu_a6a3321e'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnConcatenationLayerImpl.o): in function `__sti____cudaRegisterAll()':
tmpxft_0001193a_00000000-6_MWCudnnConcatenationLayerImpl.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_21b0a3b6_32_MWCudnnConcatenationLayerImpl_cu_a480e046'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnConvLayerImpl.o): in function `MWCudnnTarget::MWConvLayerImpl::propagateSize()':
tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0xa4): undefined reference to `cudnnSetTensor4dDescriptor'
/usr/bin/ld: tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x148): undefined reference to `cudnnGetConvolutionForwardAlgorithm_v7'
/usr/bin/ld: tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x188): undefined reference to `cudnnGetConvolutionForwardWorkspaceSize'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnConvLayerImpl.o): in function `MWCudnnTarget::MWConvLayerImpl::predict()':
tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x4d0): undefined reference to `cudnnConvolutionForward'
/usr/bin/ld: tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x528): undefined reference to `cudnnAddTensor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnConvLayerImpl.o): in function `MWCudnnTarget::MWConvLayerImpl::cleanup()':
tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x714): undefined reference to `cudnnDestroyConvolutionDescriptor'
/usr/bin/ld: tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x728): undefined reference to `cudnnDestroyFilterDescriptor'
/usr/bin/ld: tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x758): undefined reference to `cudnnDestroyTensorDescriptor'
/usr/bin/ld: tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x7a4): undefined reference to `cudnnDestroyTensorDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnConvLayerImpl.o): in function `MWCudnnTarget::MWConvLayerImpl::getConvAlgoTuned()':
tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x8f8): undefined reference to `cudnnFindConvolutionForwardAlgorithmEx'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnConvLayerImpl.o): in function `MWCudnnTarget::MWConvLayerImpl::getConvAlgoWorkSpaceLimit()':
tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x9e8): undefined reference to `cudnnGetConvolutionForwardAlgorithmMaxCount'
/usr/bin/ld: tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0xa6c): undefined reference to `cudnnGetConvolutionForwardAlgorithm_v7'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnConvLayerImpl.o): in function `MWCudnnTarget::MWConvLayerImpl::MWConvLayerImpl(MWCNNLayer*, MWCudnnTarget::MWTargetNetworkImpl*, int, int, int, int, int, int, int, int, int, int, int, int, int, char const*, char const*)':
tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x10e8): undefined reference to `cudnnCreateConvolutionDescriptor'
/usr/bin/ld: tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x1100): undefined reference to `cudnnCreateFilterDescriptor'
/usr/bin/ld: tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x1114): undefined reference to `cudnnCreateTensorDescriptor'
/usr/bin/ld: tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x1168): undefined reference to `cudnnSetConvolution2dDescriptor'
/usr/bin/ld: tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x118c): undefined reference to `cudnnSetConvolutionGroupCount'
/usr/bin/ld: tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x11bc): undefined reference to `cudnnSetFilter4dDescriptor'
/usr/bin/ld: tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x11e8): undefined reference to `cudnnSetTensor4dDescriptor'
/usr/bin/ld: tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text+0x1398): undefined reference to `cudnnCreateTensorDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnConvLayerImpl.o): in function `__sti____cudaRegisterAll()':
tmpxft_0001197a_00000000-6_MWCudnnConvLayerImpl.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_15cf97f9_23_MWCudnnConvLayerImpl_cu_f4cb2b67'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnElementwiseAffineLayerImpl.o): in function `__sti____cudaRegisterAll()':
tmpxft_0001197f_00000000-6_MWCudnnElementwiseAffineLayerImpl.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_a891a31e_36_MWCudnnElementwiseAffineLayerImpl_cu_be5fe03d'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnLeakyReLULayerImpl.o): in function `__sti____cudaRegisterAll()':
tmpxft_0001198a_00000000-6_MWCudnnLeakyReLULayerImpl.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_a2e44d4e_28_MWCudnnLeakyReLULayerImpl_cu_aef10433'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnOutputLayerImpl.o): in function `__sti____cudaRegisterAll()':
tmpxft_00011996_00000000-6_MWCudnnOutputLayerImpl.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_6dd22f7f_25_MWCudnnOutputLayerImpl_cu_b6bf9137'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnSoftmaxLayerImpl.o): in function `MWCudnnTarget::MWSoftmaxLayerImpl::propagateSize()':
tmpxft_000119d2_00000000-6_MWCudnnSoftmaxLayerImpl.cudafe1.cpp:(.text+0xb0): undefined reference to `cudnnSetTensor4dDescriptor'
/usr/bin/ld: tmpxft_000119d2_00000000-6_MWCudnnSoftmaxLayerImpl.cudafe1.cpp:(.text+0xdc): undefined reference to `cudnnSetTensor4dDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnSoftmaxLayerImpl.o): in function `MWCudnnTarget::MWSoftmaxLayerImpl::predict()':
tmpxft_000119d2_00000000-6_MWCudnnSoftmaxLayerImpl.cudafe1.cpp:(.text+0x194): undefined reference to `cudnnSoftmaxForward'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnSoftmaxLayerImpl.o): in function `MWCudnnTarget::MWSoftmaxLayerImpl::cleanup()':
tmpxft_000119d2_00000000-6_MWCudnnSoftmaxLayerImpl.cudafe1.cpp:(.text+0x1dc): undefined reference to `cudnnDestroyTensorDescriptor'
/usr/bin/ld: tmpxft_000119d2_00000000-6_MWCudnnSoftmaxLayerImpl.cudafe1.cpp:(.text+0x1f0): undefined reference to `cudnnDestroyTensorDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnSoftmaxLayerImpl.o): in function `MWCudnnTarget::MWSoftmaxLayerImpl::MWSoftmaxLayerImpl(MWCNNLayer*, MWCudnnTarget::MWTargetNetworkImpl*)':
tmpxft_000119d2_00000000-6_MWCudnnSoftmaxLayerImpl.cudafe1.cpp:(.text+0x234): undefined reference to `cudnnCreateTensorDescriptor'
/usr/bin/ld: tmpxft_000119d2_00000000-6_MWCudnnSoftmaxLayerImpl.cudafe1.cpp:(.text+0x24c): undefined reference to `cudnnCreateTensorDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnSoftmaxLayerImpl.o): in function `__sti____cudaRegisterAll()':
tmpxft_000119d2_00000000-6_MWCudnnSoftmaxLayerImpl.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_8f2316dd_26_MWCudnnSoftmaxLayerImpl_cu_9b3f4490'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWElementwiseAffineLayerImplKernel.o): in function `__sti____cudaRegisterAll()':
tmpxft_000119da_00000000-6_MWElementwiseAffineLayerImplKernel.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_aeabb3d2_37_MWElementwiseAffineLayerImplKernel_cu_adec7dc0'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWLeakyReLULayerImplKernel.o): in function `__sti____cudaRegisterAll()':
tmpxft_000119e4_00000000-6_MWLeakyReLULayerImplKernel.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_dee47261_29_MWLeakyReLULayerImplKernel_cu_878a4b6d'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnCNNLayerImpl.o): in function `MWCudnnTarget::cudnn_call_line_file(cudnnStatus_t, int, char const*)':
tmpxft_000119ee_00000000-6_MWCudnnCNNLayerImpl.cudafe1.cpp:(.text+0xf28): undefined reference to `cudnnGetErrorString'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnCNNLayerImpl.o): in function `MWCudnnTarget::MWCNNLayerImpl::setDescriptorForINT8(cudnnTensorStruct*&, MWTensor<signed char>*, cudnnDataType_t, cudnnTensorFormat_t)':
tmpxft_000119ee_00000000-6_MWCudnnCNNLayerImpl.cudafe1.cpp:(.text+0x10ec): undefined reference to `cudnnSetTensor4dDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnCNNLayerImpl.o): in function `MWCudnnTarget::MWCNNLayerImpl::~MWCNNLayerImpl()':
tmpxft_000119ee_00000000-6_MWCudnnCNNLayerImpl.cudafe1.cpp:(.text+0x1148): undefined reference to `cudnnDestroyTensorDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnCNNLayerImpl.o): in function `MWCudnnTarget::MWCNNLayerImpl::createAndAddDescriptor(int)':
tmpxft_000119ee_00000000-6_MWCudnnCNNLayerImpl.cudafe1.cpp:(.text+0x176c): undefined reference to `cudnnCreateTensorDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnCNNLayerImpl.o): in function `MWCudnnTarget::MWCNNLayerImpl::getCuDNNDescriptor(MWTensorBase*)':
tmpxft_000119ee_00000000-6_MWCudnnCNNLayerImpl.cudafe1.cpp:(.text+0x18cc): undefined reference to `cudnnCreateTensorDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnCNNLayerImpl.o): in function `__sti____cudaRegisterAll()':
tmpxft_000119ee_00000000-6_MWCudnnCNNLayerImpl.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_34db9680_22_MWCudnnCNNLayerImpl_cu_40407de2'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnCNNLayerImpl.o): in function `void MWCudnnTarget::MWCNNLayerImpl::setDescriptor<float>(cudnnTensorStruct*&, MWTensor<float>*)':
tmpxft_000119ee_00000000-6_MWCudnnCNNLayerImpl.cudafe1.cpp:(.text._ZN13MWCudnnTarget14MWCNNLayerImpl13setDescriptorIfEEvRP17cudnnTensorStructP8MWTensorIT_E[_ZN13MWCudnnTarget14MWCNNLayerImpl13setDescriptorIfEEvRP17cudnnTensorStructP8MWTensorIT_E]+0x78): undefined reference to `cudnnSetTensorNdDescriptor'
/usr/bin/ld: tmpxft_000119ee_00000000-6_MWCudnnCNNLayerImpl.cudafe1.cpp:(.text._ZN13MWCudnnTarget14MWCNNLayerImpl13setDescriptorIfEEvRP17cudnnTensorStructP8MWTensorIT_E[_ZN13MWCudnnTarget14MWCNNLayerImpl13setDescriptorIfEEvRP17cudnnTensorStructP8MWTensorIT_E]+0xc8): undefined reference to `cudnnSetTensor4dDescriptor'
/usr/bin/ld: /home/jetson/Documents/safe_landing/LoadSafeLandingNetwork/examples/../libLoadSafeLandingNetwork.a(MWCudnnCNNLayerImpl.o): in function `void MWCudnnTarget::MWCNNLayerImpl::setDescriptor<signed char>(cudnnTensorStruct*&, MWTensor<signed char>*)':
tmpxft_000119ee_00000000-6_MWCudnnCNNLayerImpl.cudafe1.cpp:(.text._ZN13MWCudnnTarget14MWCNNLayerImpl13setDescriptorIaEEvRP17cudnnTensorStructP8MWTensorIT_E[_ZN13MWCudnnTarget14MWCNNLayerImpl13setDescriptorIaEEvRP17cudnnTensorStructP8MWTensorIT_E]+0x78): undefined reference to `cudnnSetTensorNdDescriptor'
/usr/bin/ld: tmpxft_000119ee_00000000-6_MWCudnnCNNLayerImpl.cudafe1.cpp:(.text._ZN13MWCudnnTarget14MWCNNLayerImpl13setDescriptorIaEEvRP17cudnnTensorStructP8MWTensorIT_E[_ZN13MWCudnnTarget14MWCNNLayerImpl13setDescriptorIaEEvRP17cudnnTensorStructP8MWTensorIT_E]+0xc8): undefined reference to `cudnnSetTensor4dDescriptor'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/cmake_test.dir/build.make:103: cmake_test] Error 1
make[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/cmake_test.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

I’ve double checked the include and library directories and see that the CMake output matches the command line invoked -L and -I flags. So it seems like the libraries should be found and now there is something else keeping them from linking? Am I missing something that needs to be done higher up in my CMakeLists.txt to prepare the linker?

Any help is greatly appreciated. Thank you.

It is because the library libLoadSafeLandingNetwork.a is compiled with rdc=true. And you are using static library, so the object files are not linked, so is the device code in these object files.

When you use nvcc to link the static library, nvcc would link the device code automatically.

When you use cmake to build, it would use gcc to link the static library, and gcc would not link the device code.

One solution is to use GPU Coder to generate dynamic library instead of static library. In such case GPU Coder would link the device code when creating the library.