# BUILD\_SHARED\_LIBS Release and Debug

**URL:** <https://discourse.cmake.org/t/build-shared-libs-release-and-debug/12699>\
**Category:** Code\
**Tags:** os:windows\
**Created:** [October 7, 2024, 4:49am UTC](https://discourse.cmake.org/t/build-shared-libs-release-and-debug/12699 "2024-10-07T04:49:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sea\_Sea](https://discourse.cmake.org/user_avatar/discourse.cmake.org/sea_sea/32/4025_2.png) [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)\
**Post date:** [October 7, 2024, 4:49am UTC](https://discourse.cmake.org/t/build-shared-libs-release-and-debug/12699/1 "2024-10-07T04:49:13Z")

</div>

```auto
mkdir build 
cd build
cmake -DBUILD_SHARED_LIBS Debug ..
cmake -DBUILD_SHARED_LIBS Release ..

```

If I already build with debug, and then build release without any make clean or delete folder.  
Does Debug affect the release library?

Shall I mkdir another build-Release folder and then build release?

---

<div class="post-metadata">

**Author:** ![retif](https://discourse.cmake.org/user_avatar/discourse.cmake.org/retif/32/1776_2.png) [@retif](https://discourse.cmake.org/u/retif)\
**Post date:** [October 7, 2024, 6:00am UTC](https://discourse.cmake.org/t/build-shared-libs-release-and-debug/12699/2 "2024-10-07T06:00:19Z")

</div>

Not sure what you wanted to do in the first place, because these configuration commands don’t look right. The [BUILD\_SHARED\_LIBS](https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html) is a boolean type of variable, and `Debug`/`Release` strings are supposed to be used as values for [CMAKE\_BUILD\_TYPE](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html) variable (_for single-config generators, that is_).

And so what I would expect to see is:

```sh
$ cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=1 ..
$ cmake --build .

$ cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 ..
$ cmake --build .

```

If you have `BUILD_SHARED_LIBS` as an option (_cache variable_) in your project, then you won’t need to set it inline in CLI for the second time.

And then if your question is whether the second build (`Release`) will affect the first build (`Debug`) artifacts, then in general it won’t (_but that of course depends on your particular project_), unless you don’t have [CMAKE\_DEBUG\_POSTFIX](https://cmake.org/cmake/help/latest/variable/CMAKE_DEBUG_POSTFIX.html) set, because in that case `Release` binaries will overwrite `Debug` binaries. Also note that even if you do have it set, in case of executables you will still need to explicitly set the corresponding target property.
