Link failing with latest 12.2 toolkit

A project that compiled fine under 12.1 now refuses to cooperate:

/usr/bin/c++ CMakeFiles/debayer_buffer.dir/tests/debayer/cuda/debayerBuffer.cpp.o CMakeFiles/debayer_buffer.dir/tests/debayer/cuda/KernelDebayerBufferCUDA.cu.o CMakeFiles/debayer_buffer.dir/cmake_device_link.o -o debayer_buffer -Wl,-rpath,/usr/local/cuda/lib64 /usr/local/cuda/lib64/libcudart.so -lcudadevrt -lcudart_static -lrt -lpthread -ldl

/usr/bin/ld: cannot find -lcudadevrt: No such file or directory
/usr/bin/ld: cannot find -lcudart_static: No such file or directory

Incidentally, I use cmake to configure the project - version is latest: 3.26.4

Also, I have added usr/local/cuda-12.2/targets/x86_64-linux/lib/ to my LIBRARY_PATH env variable, as these are static libraries that are not found.

you appear to be using /usr/bin/c++ as the linker (to wit: /usr/bin/ld). cudadevrt is intended for applications that require device linking, and the ld tool is a host linker.

Simultaneously specifying libcudart.so and -lcudart_static to the linker is not sensible.

You may want to clean up what you are doing first.

If you have a normal linux cuda install, please indicate the contents of your /usr/local/cuda/lib64 directory.

Thanks. The exact same command works fine with 12.1 toolkit. CMake creates the command line, and it breaks with 12.2.

Ok, if you don’t want to provide the information I asked for, I won’t be able to help.

missed that, here you go :

/usr/local/cuda/lib64:
cmake                     libcudart.so.12.2.53            libcudnn_cnn_infer_static_v8.a  libcudnn.so                   libcufile.so            libcurand_static.a           libnppc.so.12            libnppif.so.12          libnppisu.so.12         libnvJitLink.so.12.2.91       libnvrtc.so.12.2.91
libaccinj64.so            libcudart_static.a              libcudnn_cnn_train.so           libcudnn.so.8                 libcufile.so.0          libcusolver_lapack_static.a  libnppc.so.12.1.1.14     libnppif.so.12.1.1.14   libnppisu.so.12.1.1.14  libnvJitLink_static.a         libnvrtc_static.a
libaccinj64.so.12.2       libcudnn_adv_infer.so           libcudnn_cnn_train.so.8         libcudnn.so.8.9.3             libcufile.so.1.7.0      libcusolver_metis_static.a   libnppc_static.a         libnppif_static.a       libnppisu_static.a      libnvjpeg.so                  libnvToolsExt.so
libaccinj64.so.12.2.60    libcudnn_adv_infer.so.8         libcudnn_cnn_train.so.8.9.3     libcufft.so                   libcufile_static.a      libcusolverMg.so             libnppial.so             libnppig.so             libnppitc.so            libnvjpeg.so.12               libnvToolsExt.so.1
libcheckpoint.so          libcudnn_adv_infer.so.8.9.3     libcudnn_cnn_train_static.a     libcufft.so.11                libcufilt.a             libcusolverMg.so.11          libnppial.so.12          libnppig.so.12          libnppitc.so.12         libnvjpeg.so.12.1.1.14        libnvToolsExt.so.1.0.0
libcublasLt.so            libcudnn_adv_infer_static.a     libcudnn_cnn_train_static_v8.a  libcufft.so.11.0.8.15         libcuinj64.so           libcusolverMg.so.11.5.0.53   libnppial.so.12.1.1.14   libnppig.so.12.1.1.14   libnppitc.so.12.1.1.14  libnvjpeg_static.a            libOpenCL.so
libcublasLt.so.12         libcudnn_adv_infer_static_v8.a  libcudnn_ops_infer.so           libcufft_static.a             libcuinj64.so.12.2      libcusolver.so               libnppial_static.a       libnppig_static.a       libnppitc_static.a      libnvperf_host.so             libOpenCL.so.1
libcublasLt.so.12.2.1.16  libcudnn_adv_train.so           libcudnn_ops_infer.so.8         libcufft_static_nocallback.a  libcuinj64.so.12.2.60   libcusolver.so.11            libnppicc.so             libnppim.so             libnpps.so              libnvperf_host_static.a       libOpenCL.so.1.0
libcublasLt_static.a      libcudnn_adv_train.so.8         libcudnn_ops_infer.so.8.9.3     libcufftw.so                  libculibos.a            libcusolver.so.11.5.0.53     libnppicc.so.12          libnppim.so.12          libnpps.so.12           libnvperf_target.so           libOpenCL.so.1.0.0
libcublas.so              libcudnn_adv_train.so.8.9.3     libcudnn_ops_infer_static.a     libcufftw.so.11               libcupti.so             libcusolver_static.a         libnppicc.so.12.1.1.14   libnppim.so.12.1.1.14   libnpps.so.12.1.1.14    libnvptxcompiler_static.a     libpcsamplingutil.so
libcublas.so.12           libcudnn_adv_train_static.a     libcudnn_ops_infer_static_v8.a  libcufftw.so.11.0.8.15        libcupti.so.12          libcusparse.so               libnppicc_static.a       libnppim_static.a       libnpps_static.a        libnvrtc-builtins.so          stubs
libcublas.so.12.2.1.16    libcudnn_adv_train_static_v8.a  libcudnn_ops_train.so           libcufftw_static.a            libcupti.so.2023.2.0    libcusparse.so.12            libnppidei.so            libnppist.so            libnvblas.so            libnvrtc-builtins.so.12.2
libcublas_static.a        libcudnn_cnn_infer.so           libcudnn_ops_train.so.8         libcufile_rdma.so             libcupti_static.a       libcusparse.so.12.1.1.53     libnppidei.so.12         libnppist.so.12         libnvblas.so.12         libnvrtc-builtins.so.12.2.91
libcudadevrt.a            libcudnn_cnn_infer.so.8         libcudnn_ops_train.so.8.9.3     libcufile_rdma.so.1           libcurand.so            libcusparse_static.a         libnppidei.so.12.1.1.14  libnppist.so.12.1.1.14  libnvblas.so.12.2.1.16  libnvrtc-builtins_static.a
libcudart.so              libcudnn_cnn_infer.so.8.9.3     libcudnn_ops_train_static.a     libcufile_rdma.so.1.7.0       libcurand.so.10         libmetis_static.a            libnppidei_static.a      libnppist_static.a      libnvJitLink.so         libnvrtc.so
libcudart.so.12           libcudnn_cnn_infer_static.a     libcudnn_ops_train_static_v8.a  libcufile_rdma_static.a       libcurand.so.10.3.3.53  libnppc.so                   libnppif.so              libnppisu.so            libnvJitLink.so.12      libnvrtc.so.12

/usr/local/cuda/lib64/cmake:
cub  libcudacxx  thrust

/usr/local/cuda/lib64/cmake/cub:
cub-config.cmake  cub-config-version.cmake  cub-header-search.cmake

/usr/local/cuda/lib64/cmake/libcudacxx:
libcudacxx-config.cmake  libcudacxx-config-version.cmake  libcudacxx-header-search.cmake

/usr/local/cuda/lib64/cmake/thrust:
FindTBB.cmake  README.md  thrust-config.cmake  thrust-config-version.cmake  thrust-header-search.cmake

/usr/local/cuda/lib64/stubs:
libcublasLt.so  libcuda.so   libcufftw.so  libcusolverMg.so  libcusparse.so  libnppial.so  libnppidei.so  libnppig.so  libnppist.so  libnppitc.so  libnvidia-ml.so  libnvjpeg.so
libcublas.so    libcufft.so  libcurand.so  libcusolver.so    libnppc.so      libnppicc.so  libnppif.so    libnppim.so  libnppisu.so  libnpps.so    libnvJitLink.so  libnvrtc.so

libcudadevrt.a and libcudart_static.a are there.

The link command you are using is missing a -L switch. I’m not sure why. It may be a characteristic of cmake. The -Wl,-rpath switch although it seems to be doing the “same thing” is not a replacement for it.

There is some path that the linker is using to locate the libraries in the 12.1 case that you have not updated to be correct for the 12.2 case. I don’t know what it is.

If I were “fixing” this, I would tell you to issue the command as follows:

/usr/bin/c++ CMakeFiles/debayer_buffer.dir/tests/debayer/cuda/debayerBuffer.cpp.o CMakeFiles/debayer_buffer.dir/tests/debayer/cuda/KernelDebayerBufferCUDA.cu.o CMakeFiles/debayer_buffer.dir/cmake_device_link.o -o debayer_buffer -Wl,-rpath,/usr/local/cuda/lib64 -L/usr/local/cuda/lib64 /usr/local/cuda/lib64/libcudart.so -lcudadevrt -lcudart_static -lrt -lpthread -ldl

But I can’t fix cmake for you. I don’t use it very much.

I guess LIBRARY_PATH is sort of a “replacement” for the -L switch. I pretty much never use that either. You could try updating your LIBRARY_PATH env var to include /usr/local/cuda/lib64 although I don’t know if cmake picks up that environment, or not.

Thanks, yes it should find those libraries. I think something is messed up with my build environment, will investigate that.

@Robert_Crovella yes, it was a local problem with my system. Sorry for the noise.