# find\_library does not find stdc++fs

**URL:** https://discourse.cmake.org/t/find-library-does-not-find-stdc-fs/4764
**Category:** Usage
**Tags:** os:linux
**Created:** [January 2, 2022, 10:28pm UTC](https://discourse.cmake.org/t/find-library-does-not-find-stdc-fs/4764 "2022-01-02T22:28:44Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [January 3, 2022, 6:41am UTC](https://discourse.cmake.org/t/find-library-does-not-find-stdc-fs/4764/2 "2022-01-03T06:41:17Z")

</div>

I’m not sure why you’d be wanting to find this particular library. I’d expect the compiler would find the right one if you linked to `stdc++fs`. Either of the following should work:

```cmake
target_link_libraries(SomeTarget PRIVATE stdc++fs)

```

To answer your question more directly, `find_library()` won’t be looking in any of the directories where you have a `libstdc++fs.*` file. You’d have to provide it with hints, but really I’d be looking to let the compiler provide it on its own with the default linker search path.

You would need to provide the logic that works out whether `libstdc++fs.*` needs to be linked rather than simply relying on whether you can find such a library or not. That probably means logic that only links it for specific version ranges of specific compilers. For example, [cppreference.com](https://en.cppreference.com/w/cpp/filesystem) contains the following note near the bottom of that page:

> Using this library may require additional compiler/linker options. GNU implementation prior to 9.1 requires linking with `-lstdc++fs` and LLVM implementation prior to LLVM 9.0 requires linking with `-lc++fs`.

---

_[View the full topic](https://discourse.cmake.org/t/find-library-does-not-find-stdc-fs/4764)._
