# setting generated shared library path for client

**URL:** https://discourse.cmake.org/t/setting-generated-shared-library-path-for-client/7649
**Category:** Usage
**Created:** [March 9, 2023, 4:59pm UTC](https://discourse.cmake.org/t/setting-generated-shared-library-path-for-client/7649 "2023-03-09T16:59:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![adaldev](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@adaldev](https://discourse.cmake.org/u/adaldev)
#### Post date: [March 9, 2023, 4:59pm UTC](https://discourse.cmake.org/t/setting-generated-shared-library-path-for-client/7649/1 "2023-03-09T16:59:36Z")

</div>

Hi,

When “installing” a shared library target, is there a special way to declare the resulting .so/.dll path.  
So far I manage it like my static libraries and, at least on windows/mingw/make, my client code using the dll compiles but when I try to execute it, It crashes with a dll-no-found error.  
My workaround is to add the .so/.dll directory to the user path but its not practical if I install each .so/.dll in its own dir.  
Is there another way or the solution is to pack all my produced .so/.dll into a single directory (/usr/lib, or a single custom directory added to system path) ?

NB By “installing” I mean creating a MyTargetConfig.cmake file and MyTargetTargetsxxx.cmake files

Thanks  
A.  
PS I realize that I will need a way to distinguish between the different configurations (debug/release) of the shared library, issue that does not exist with static lib as I can use different paths for different configurations. How to be sure that, say, client.exe in debug will use the debug version of MyLib.so/.dll and the release on will use the release version.  
I’m currently failing to find a tutorial that covers completely these questions

---

<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: [March 11, 2023, 1:14am UTC](https://discourse.cmake.org/t/setting-generated-shared-library-path-for-client/7649/2 "2023-03-11T01:14:16Z")

</div>

Typically you use `install(RUNTIME DESTINATION)` and/or `CMAKE_RUNTIME_OUTPUT_DIRECTORY` to put `.dll` files into the same place.

---

<div class="post-metadata">

### Author: ![adaldev](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@adaldev](https://discourse.cmake.org/u/adaldev)
#### Post date: [March 13, 2023, 10:58am UTC](https://discourse.cmake.org/t/setting-generated-shared-library-path-for-client/7649/3 "2023-03-13T10:58:56Z")

</div>

Hi, thanks for your answer,

If I understand you well, you’re recommanding to put all my dlls into a single reserved directory, that I must, therefore, add to my path?

In this case, is there a way, within, CMAKE, to (permanently) this this path into the environment path user variable?

Thanks  
A.

---

<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: [March 15, 2023, 1:09am UTC](https://discourse.cmake.org/t/setting-generated-shared-library-path-for-client/7649/4 "2023-03-15T01:09:51Z")

</div>

> [@adaldev](#):
>
> In this case, is there a way, within, CMAKE, to (permanently) this this path into the environment path user variable?

You could write a script that does the necessary. I presume it has to do something with the registry, but I don’t know. If it is, CMake has some support for _reading_ the registry, but I don’t think writing is exposed.
