# Creating shared library using Cmake

**URL:** https://discourse.cmake.org/t/creating-shared-library-using-cmake/12960
**Category:** Usage
**Created:** [November 13, 2024, 11:09am UTC](https://discourse.cmake.org/t/creating-shared-library-using-cmake/12960 "2024-11-13T11:09:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Umer](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/u/aca169/32.png) [@Umer](https://discourse.cmake.org/u/Umer)
#### Post date: [November 13, 2024, 11:09am UTC](https://discourse.cmake.org/t/creating-shared-library-using-cmake/12960/1 "2024-11-13T11:09:34Z")

</div>

Hello everyone,

I need some guidance on creating a shared library using CMake. My C++ project is already configured in Visual Studio, with the target set to generate a DLL library. I now need to create a shared library using the same C++ project.

I’ve set up most of the configuration, but I am facing a lot of errors, and I have no idea how to deal with them. Any advice or examples would be greatly appreciated.

Thanks in advance!

Umer Fiaz

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [November 13, 2024, 7:42pm UTC](https://discourse.cmake.org/t/creating-shared-library-using-cmake/12960/2 "2024-11-13T19:42:02Z")

</div>

You may find a modern example project here

> <https://github.com/ClausKlein/cpp-lib-template/blob/1fca6de82c883898301066a29ce4f6ab9bb6d2c3/CMakeLists.txt#L60>

---

<div class="post-metadata">

### Author: ![Umer](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/u/aca169/32.png) [@Umer](https://discourse.cmake.org/u/Umer)
#### Post date: [November 15, 2024, 9:24am UTC](https://discourse.cmake.org/t/creating-shared-library-using-cmake/12960/3 "2024-11-15T09:24:01Z")

</div>

Thanks a lot for your reply. I checked the example in detail, but it’s not working for me. Have a great day.

Best regards,  
Umer Fiaz.

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [November 15, 2024, 3:25pm UTC](https://discourse.cmake.org/t/creating-shared-library-using-cmake/12960/5 "2024-11-15T15:25:12Z")

</div>

Not working? see [Workflow runs · ClausKlein/cpp-lib-template](https://github.com/ClausKlein/cpp-lib-template/actions)
