Open MHebes opened 10 months ago
Hey @MHebes,
Right now we've hardcoded static linking to the MSVC runtime libraries, but we're working on removing the limitation. Until we've merged those changes the temporary work around is to opt in for static linking of the runtime libraries yourself by similarly setting the MSVC_RUNTIME_LIBRARY
target property in your project.
I gotcha @fealebenpae—thanks so much for the link and info!
Would you happen to have a sense of how hard it would be for me to monkey patch to build with dynamic linking? Assuming I didn't care about any platforms other than desktop windows (my project produces many binaries so static linking would be pretty burdensome).
In other words, do you think that removing the set_property(...MSVC_RUNTIME_LIBRARY)
lines from realm-cpp/CMakeLists.txt
like you do in that PR draft be good enough or is there a deeper reason for the static linking other than "simplicity in deployment"?
You can certainly edit the listfile - there is a similar change in a submodule you have to make, but that's about it. However, there is the added complication of our dependencies on Windows - we rely on OpenSSL and zlib and the prebuilt copies we host and link against are also built to statically link the runtime libraries. You would need to provide your own copies of OpenSSL and zlib that satisfy CMake's find_package
and call find_package(OpenSSL REQUIRED)
, find_package(zlib REQUIRED)
, and set(REALM_USE_SYSTEM_OPENSSL ON)
in your project's CMakeLists.txt prior to including realm-cpp.
The vcpkg integration PR I originally linked to is supposed to solve this generally, as we'll be pulling OpenSSL and zlib as vcpkg dependencies and vcpkg can build with the correct RuntimeLibrary
setting. It's definitely possible to achieve the same yourself if you're handy with CMake, but my suggestion would be to wait for the vcpkg integration to land and consume the library that way.
I am trying to build a basic hello world program, and am getting some linker errors.
I'm on windows with visual studio 2022 (
cl.exe
version isMicrosoft (R) C/C++ Optimizing Compiler Version 19.38.33130 for x86
).Just tons of static/dynamic linking errors, e.g.
Here's a MRE:
Commands:
There's a slightly suspicious line in the CMakeLists that may be related to the issue:
https://github.com/realm/realm-cpp/blob/43a68815c11eb7fdd8010eef91157419d2e17b64/CMakeLists.txt#L120
Any thoughts on how I should fix this issue?