# Best practice for finding dlls from the buildtree

**URL:** <https://discourse.cmake.org/t/best-practice-for-finding-dlls-from-the-buildtree/7201>\
**Category:** Code\
**Created:** [January 4, 2023, 11:04pm UTC](https://discourse.cmake.org/t/best-practice-for-finding-dlls-from-the-buildtree/7201 "2023-01-04T23:04:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![neundorf](https://discourse.cmake.org/user_avatar/discourse.cmake.org/neundorf/32/2075_2.png) [@neundorf](https://discourse.cmake.org/u/neundorf)\
**Post date:** [January 4, 2023, 11:04pm UTC](https://discourse.cmake.org/t/best-practice-for-finding-dlls-from-the-buildtree/7201/1 "2023-01-04T23:04:01Z")

</div>

Hi,

I’m used to RPATH under Linux, which makes running executables in the build  
tree simple under Linux. Whatever shared libs have been linked, the executable  
will find them via RPATH.

AFAIK such a feature still doesn’t exist under Windows.  
So what is the recommended way to deal with this under Windows ?  
I.e. if I link against some dlls which are somewhere else on the system, how  
will the executable find them ?  
Should I copy them to the build output directory during the configure-step  
after find\_package() ?  
Or create a bat-file which sets PATH ? Would this work with debugging in Visual  
Studio ? Or is there some other solution ?  
For dlls built in the project, I guess the output directory should be set to  
the same directory ?

Thanks  
Alex

---

<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:** [January 4, 2023, 11:32pm UTC](https://discourse.cmake.org/t/best-practice-for-finding-dlls-from-the-buildtree/7201/2 "2023-01-04T23:32:38Z")

</div>

For your own libraries, I recommend putting them all in the same place. For externals, you can assume they’ll be available via `PATH` or use the `$<TARGET_RUNTIME_DLLS>` generator expression.
