Correct usage of WINDOWS_EXPORT_ALL_SYMBOLS

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..

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:

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?

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/