# Correct usage of WINDOWS\_EXPORT\_ALL\_SYMBOLS

**URL:** <https://discourse.cmake.org/t/correct-usage-of-windows-export-all-symbols/15306>\
**Category:** Code\
**Created:** [November 14, 2025, 2:11pm UTC](https://discourse.cmake.org/t/correct-usage-of-windows-export-all-symbols/15306 "2025-11-14T14:11:41Z")\
**Posts on this page:** 2\
**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:** [November 14, 2025, 2:11pm UTC](https://discourse.cmake.org/t/correct-usage-of-windows-export-all-symbols/15306/1 "2025-11-14T14:11:41Z")

</div>

I’m trying to use a library named Alglib which has no CMake support. Such support is provided here: [GitHub - S-Dafarra/alglib-cmake: CMake files to download and build ALGLIB, to be used as an external library.](https://github.com/S-Dafarra/alglib-cmake).

I can build it as a shared library on windows with msvc, but, when I try to link it with an executable, I’ve got undefined symbols. If I build as a static library, it works fine.

Alglib code does not contain export code for windows dll but the CMakeLists linked above uses `set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)`.

According to the documentation, explicitly marking some entities with `__declspec(dllimport)` would remain mandatory?

For instance, in Alglib I see:

```cpp
namespace alglib {
...
extern const xparams &xdefault;
...
}

```

Is it correct that for this symbol to be visible, `WINDOWS_EXPORT_ALL_SYMBOLS` is not enough and `__declspec(dllimport)` should be added to Alglib sources?

---

<div class="post-metadata">

**Author:** ![bill.hoffman](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bill.hoffman/32/13_2.png) [@bill.hoffman](https://discourse.cmake.org/u/bill.hoffman)\
**Post date:** [November 14, 2025, 7:37pm UTC](https://discourse.cmake.org/t/correct-usage-of-windows-export-all-symbols/15306/2 "2025-11-14T19:37:13Z")

</div>

Yes, for exposing variables outside of the DLL it is required to mark up the code. There is a blog about this that can be found here: [https://www.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/](https://www.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/)
