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/ CMakeFiles/debayer_buffer.dir/cmake_device_link.o -o debayer_buffer -Wl,-rpath,/usr/local/cuda/lib64 /usr/local/cuda/lib64/ -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 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 :

cmake                       libcudnn_cnn_infer_static_v8.a                     libcurand_static.a               libcudart_static.a                      libcusolver_lapack_static.a  libnvJitLink_static.a         libnvrtc_static.a          libcusolver_metis_static.a   libnppc_static.a         libnppif_static.a       libnppisu_static.a                           libcufile_static.a                     libcudnn_cnn_train_static.a                libcufilt.a               libcudnn_adv_infer_static.a     libcudnn_cnn_train_static_v8.a   libnvjpeg_static.a           libcudnn_adv_infer_static_v8.a           libcufft_static.a                  libnppial_static.a       libnppig_static.a       libnppitc_static.a             libcufft_static_nocallback.a                      libnvperf_host_static.a
libcublasLt_static.a                  libculibos.a             libcudnn_ops_infer_static.a                  libcusolver_static.a    libnvptxcompiler_static.a           libcudnn_adv_train_static.a     libcudnn_ops_infer_static_v8.a               libnppicc_static.a       libnppim_static.a       libnpps_static.a          stubs    libcudnn_adv_train_static_v8.a           libcufftw_static.a          
libcublas_static.a              libcupti_static.a
libcudadevrt.a               libcusparse_static.a  libnvrtc-builtins_static.a         libcudnn_ops_train_static.a         libmetis_static.a            libnppidei_static.a      libnppist_static.a           libcudnn_cnn_infer_static.a     libcudnn_ops_train_static_v8.a  libcufile_rdma_static.a               

cub  libcudacxx  thrust

cub-config.cmake  cub-config-version.cmake  cub-header-search.cmake

libcudacxx-config.cmake  libcudacxx-config-version.cmake  libcudacxx-header-search.cmake

FindTBB.cmake  thrust-config.cmake  thrust-config-version.cmake  thrust-header-search.cmake


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/ 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/ -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.