when i use cmake to complie my project,it have complie successfully,but when i got the link stage
but i got the probelm like this
ld: not found. -lcusolver: No file or directory
ld: Not found -lcublas: No file or directory
ld: Not found -lcufft: No file or directory
when i add the libs in the shell path,this time it doesn’t works
it seems that i need add the libcusolver.so,libcubals.so,libcufft.so in the CmakeLists.txt,i know i can add this by -L/path/to/libraries/…,however how can i add it in the cmakeLists.txt
Are you using
find_package(CUDA)? The latter is deprecated and you should use the CUDA language instead. I think some of this comes from
All these libraries have target representations provided by the
You would link to the
CUDA::cusolver target which knows where the actual library is on disk.
i use the hpc_sdk,i can find the cusolver.so,cublas.so,cufft.so,but i can’t install the CUDAToolKit,so could tell how to add the shared time library in the project
find_package(CUDAToolkit) is aware of the hpc sdk layout and will find the components CUDA toolkit components inside of it.
Edit: You will want to use the newest version of CMake possible ( at a minimum 3.21 ) to get HPC SDK support from
If for some reason you can’t upgrade CMake, the HPC SDK also ships with the NVHPC module which will bring in support for these libraries.
That can be used like:
find_package(NVHPC REQUIRED COMPONENTS MATH)
target_link_libraries(helloworld PRIVATE NVHPC::MATH)
NVHPC::MATH target will ensure you link to cublas, cusolver, curand, cusparse, etc.