# Got warning "Cannot generate a safe runtime search"

**URL:** https://discourse.cmake.org/t/got-warning-cannot-generate-a-safe-runtime-search/7398
**Category:** Usage
**Tags:** os:linux, gen:makefiles
**Created:** [February 3, 2023, 2:39pm UTC](https://discourse.cmake.org/t/got-warning-cannot-generate-a-safe-runtime-search/7398 "2023-02-03T14:39:12Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![zhiqiu](https://discourse.cmake.org/user_avatar/discourse.cmake.org/zhiqiu/32/3141_2.png) [@zhiqiu](https://discourse.cmake.org/u/zhiqiu)
#### Post date: [February 3, 2023, 2:39pm UTC](https://discourse.cmake.org/t/got-warning-cannot-generate-a-safe-runtime-search/7398/1 "2023-02-03T14:39:12Z")

</div>

I write two lines of find\_library in my project,

```auto
  find_library(CUDASTUB libcuda.so HINTS ${CUDA_TOOLKIT_ROOT_DIR}/lib64/stubs/ REQUIRED)
  find_library(CUDASO libcuda.so.1 HINTS ${CUDASO_LIB} REQUIRED)

```

the first one finds libcuda.so, and the second one finds libcuda.so.1.

And i got the following warning,

```auto
CMake Warning at cmake/core.cmake:68 (add_executable):
  Cannot generate a safe runtime search path for target test_analyze_ir
  because files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libcuda.so.1] in /usr/local/cuda/lib64/stubs may be hidden by files in:
      /usr/local/cuda-11.2/compat

  Some of these libraries may not be found correctly.

```

I think cmake is confusing about these two dso?

---

<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: [February 8, 2023, 4:39pm UTC](https://discourse.cmake.org/t/got-warning-cannot-generate-a-safe-runtime-search/7398/2 "2023-02-08T16:39:54Z")

</div>

CMake is saying that you have library A in directory X and library B in directory Y. However, a library of name A also exists in Y and B in X. Therefore, there is no rpath setting that will guarantee that the libraries chosen at build time will actually be used because instead of X/A and Y/B, the runtime will instead find either X/A and X/B or Y/A and Y/B.
