# ld: not found. -lcusolver: No file or directory

**URL:** https://discourse.cmake.org/t/ld-not-found-lcusolver-no-file-or-directory/9205
**Category:** Usage
**Tags:** os:linux
**Created:** [October 16, 2023, 4:08pm UTC](https://discourse.cmake.org/t/ld-not-found-lcusolver-no-file-or-directory/9205 "2023-10-16T16:08:58Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![A\_007](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/35a633/32.png) [@A\_007](https://discourse.cmake.org/u/A_007)
#### Post date: [October 16, 2023, 4:08pm UTC](https://discourse.cmake.org/t/ld-not-found-lcusolver-no-file-or-directory/9205/1 "2023-10-16T16:08:58Z")

</div>

Hello  
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

 ![image](https://discourse.cmake.org/uploads/default/original/2X/e/effe27df12666bf73d89e7fbd5a70a6d1a735ae7.png)

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  
–best wishes

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [October 16, 2023, 5:16pm UTC](https://discourse.cmake.org/t/ld-not-found-lcusolver-no-file-or-directory/9205/2 "2023-10-16T17:16:21Z")

</div>

Are you using `enable_language(CUDA)` or `find_package(CUDA)`? The latter is deprecated and you should use the CUDA language instead. I think some of this comes from `CUDAToolkit` though?

Cc: @robert.maynard

---

<div class="post-metadata">

### Author: ![robert.maynard](https://discourse.cmake.org/user_avatar/discourse.cmake.org/robert.maynard/32/4_2.png) [@robert.maynard](https://discourse.cmake.org/u/robert.maynard)
#### Post date: [October 16, 2023, 5:59pm UTC](https://discourse.cmake.org/t/ld-not-found-lcusolver-no-file-or-directory/9205/3 "2023-10-16T17:59:17Z")

</div>

All these libraries have target representations provided by the `find_package(CUDAToolkit)` module.  
You would link to the `CUDA::cusolver` target which knows where the actual library is on disk.

---

<div class="post-metadata">

### Author: ![A\_007](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/35a633/32.png) [@A\_007](https://discourse.cmake.org/u/A_007)
#### Post date: [October 17, 2023, 1:43am UTC](https://discourse.cmake.org/t/ld-not-found-lcusolver-no-file-or-directory/9205/4 "2023-10-17T01:43:13Z")

</div>

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

---

<div class="post-metadata">

### Author: ![robert.maynard](https://discourse.cmake.org/user_avatar/discourse.cmake.org/robert.maynard/32/4_2.png) [@robert.maynard](https://discourse.cmake.org/u/robert.maynard)
#### Post date: [October 17, 2023, 12:49pm UTC](https://discourse.cmake.org/t/ld-not-found-lcusolver-no-file-or-directory/9205/5 "2023-10-17T12:49:27Z")

</div>

`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 `find_package(CUDAToolkit)`.

---

<div class="post-metadata">

### Author: ![robert.maynard](https://discourse.cmake.org/user_avatar/discourse.cmake.org/robert.maynard/32/4_2.png) [@robert.maynard](https://discourse.cmake.org/u/robert.maynard)
#### Post date: [October 17, 2023, 12:56pm UTC](https://discourse.cmake.org/t/ld-not-found-lcusolver-no-file-or-directory/9205/6 "2023-10-17T12:56:27Z")

</div>

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:

```cmake
  project(helloworld CXX)

  set(NVHPC_CUDA_VERSION 11.0)
  find_package(NVHPC REQUIRED COMPONENTS MATH)

  add_executable(helloworld "helloworld.cpp")
  target_link_libraries(helloworld PRIVATE NVHPC::MATH)

```

The `NVHPC::MATH` target will ensure you link to cublas, cusolver, curand, cusparse, etc.
