# Few questions about find\_library()

**URL:** <https://discourse.cmake.org/t/few-questions-about-find-library/10332>\
**Category:** Code\
**Created:** [March 8, 2024, 7:31pm UTC](https://discourse.cmake.org/t/few-questions-about-find-library/10332 "2024-03-08T19:31:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![WaltOnline](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/w/9dc877/32.png) [@WaltOnline](https://discourse.cmake.org/u/WaltOnline)\
**Post date:** [March 8, 2024, 7:31pm UTC](https://discourse.cmake.org/t/few-questions-about-find-library/10332/1 "2024-03-08T19:31:35Z")

</div>

Hi!  
I have lib files in directory, so I set

```auto
set(MYLIBSDIR "C:/Users/User1/Desktop/math_libs")
find_library(RESULT NAMES lib PATHS "${MYLIBSDIR}/lib")
message("RESULT: " ${RESULT})

```

libs name:

> lib\_trace.lib

and

> lib\_copy.lib

but it still outputs:  
`1> [CMake] RESULT3: RESULT3-NOTFOUND`

how to tell cmake to look for library that begins with lib\* ?

If I’m not mistaken I need to enter whole name of a lib and also whole path to directory where libs are, but if I enter full path to directory and full name of a lib  
then what’s the point of **find\_library()**? Why **find\_library()** isn’t recursively search into subdirectories?

Also as a sidenote:  
can I found several libraries that fits my name pattern, e.g lib\*, and then link them all with target\_link\_libraries() ?

---

<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:** [April 10, 2024, 9:42pm UTC](https://discourse.cmake.org/t/few-questions-about-find-library/10332/2 "2024-04-10T21:42:10Z")

</div>

> [@WaltOnline](#):
>
> `find_library(RESULT NAMES lib PATHS "${MYLIBSDIR}/lib")`

You’re telling CMake to search for `liblib`. Does `NAMES _trace` work? You’ll need one `find_library` per library name (with different variable names).
