# link\_directories() command Adds two directories for each directory passed to it

**URL:** https://discourse.cmake.org/t/link-directories-command-adds-two-directories-for-each-directory-passed-to-it/8794
**Category:** Code
**Tags:** os:windows, comp:msvc, gen:vs
**Created:** [August 21, 2023, 12:47pm UTC](https://discourse.cmake.org/t/link-directories-command-adds-two-directories-for-each-directory-passed-to-it/8794 "2023-08-21T12:47:39Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Malaz99](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@Malaz99](https://discourse.cmake.org/u/Malaz99)
#### Post date: [August 21, 2023, 12:47pm UTC](https://discourse.cmake.org/t/link-directories-command-adds-two-directories-for-each-directory-passed-to-it/8794/1 "2023-08-21T12:47:39Z")

</div>

link\_directories() command Adds two directories for each directory passed to it; one is the same as what I pass to the command and another with the appended Visual Studio $(Configuration) variable.

How do I prevent that?

 ![](https://discourse.cmake.org/uploads/default/original/2X/6/6e737559c89e7c81e9aff8db7fa25a940494ad7a.png)

---

<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: [August 21, 2023, 2:02pm UTC](https://discourse.cmake.org/t/link-directories-command-adds-two-directories-for-each-directory-passed-to-it/8794/2 "2023-08-21T14:02:40Z")

</div>

This looks like a build using the Visual Studio generator. I suspect that this is because, by default, CMake generates a subdirectory per-configuration to place libraries. This seems like the other half of that. I’m not sure if there’s a way to suppress it or not.

Cc: @brad.king

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [August 21, 2023, 2:44pm UTC](https://discourse.cmake.org/t/link-directories-command-adds-two-directories-for-each-directory-passed-to-it/8794/3 "2023-08-21T14:44:33Z")

</div>

See [CMake Issue 20870](https://gitlab.kitware.com/cmake/cmake/-/issues/20870) and my first reply there.

---

<div class="post-metadata">

### Author: ![Malaz99](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@Malaz99](https://discourse.cmake.org/u/Malaz99)
#### Post date: [August 22, 2023, 8:37am UTC](https://discourse.cmake.org/t/link-directories-command-adds-two-directories-for-each-directory-passed-to-it/8794/4 "2023-08-22T08:37:52Z")

</div>

Thanks; I see it, but until now I didn’t know how to solve this; I didn’t know what option to use or what policy to change. I searched a lot about that, but without any benefit. Could you tell me what I should do?

---

<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: [August 22, 2023, 10:49am UTC](https://discourse.cmake.org/t/link-directories-command-adds-two-directories-for-each-directory-passed-to-it/8794/5 "2023-08-22T10:49:27Z")

</div>

It’s an issue tracking a task to address the issue. There’s nothing to be done at the moment.
