alecthomas / entityx

EntityX - A fast, type-safe C++ Entity-Component system
MIT License
2.21k stars 295 forks source link

Shared library not working in Windows #246

Open memsharded opened 3 years ago

memsharded commented 3 years ago

EntityX is in ConanCenter: https://conan.io/center/entityx

But the shared library build has been removed for Windows: https://github.com/conan-io/conan-center-index/blob/ff8bf5423a93bd972099a16f2a7b2646d53b7f69/recipes/entityx/all/conanfile.py#L52

Removing those lines, the output shows as the result of CMake install:

-- Install configuration: "Release"
  -- Installing: C:/.../lib/pkgconfig/entityx.pc
  -- Installing: C:/.../include/entityx
  -- Installing: C:/.../include/entityx/deps
  -- Installing: C:/.../include/entityx/deps/Dependencies.h
...
  -- Installing: C:/.../include/entityx/System.h
  -- Installing: C:/.../include/entityx/tags
  -- Installing: C:/.../include/entityx/tags/TagsComponent.h
  -- Installing: C:/.../bin/entityx.dll

Further inspection shows that the .lib static library is not being created at all. The ENTITYX_BUILD_SHARED is being defined.

Is this intended behavior? I can see that shared libraries are working fine in other platforms, is shared .dll library support for Windows? Thanks!

Deledrius commented 3 years ago

It appears that the issue is (in part) that the code does not mark any classes or functions to be exported with __declspec(dllexport), so no .lib file is produced by MSVC to link against. Brute-forcing it with set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) seems to mitigate but not solve the problem, as only pool_test and tags_component_test are able to compile, link, and run. The rest appear to require more work to link as a shared library in Windows. There may be issues around the usage of STL types, but I'm not certain.