You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CMake SHARED library with Emscripten toolchain is not supported #17804
Toolchain file is defined in CMakeSettings.json (set to emscripten).
I want to use dynamic linking at loadtime.
The resulting Renderer shared library project is treated and compiled as a static library.
In Visual Studio opening a CMake project the Solution Explorer displays the following
Verbose output commands:
The verbose output command for linking Renderer uses emar
While configuring CMAKE this dev warning is displayed
ADD_LIBRARY called with SHARED option but the target platform does not
support dynamic linking. Building a STATIC library instead. This may lead
to problems.
This warning is for project developers. Use -Wno-dev to suppress it.
Emscripten support for dynamic linking doesn't yet match what cmake expects so you ca't build and use SHARED libraries in the normal way.
Until we fix this you might be able to get it working by building your renderer library as an executable with the -sSIDE_MODULE link flag and then adding the resulting wasm file to the link command for the main executable.
target_link_libraries used in CMake does not allow linking executables to executables, so the workaround does not work.
However, the solution proposed in #16281 works, and it makes the cmake a whole lot cleaner.
While target_link_libraries doen't work with executables, I think can explicitly add a dependency between one executable and another and then add it to link flags just like any other linker flag.
I agree that #16281 would be great in the long term, but if you want something that works to today that isn't an option.
Activity
sbc100 commentedon Sep 6, 2022
Emscripten support for dynamic linking doesn't yet match what cmake expects so you ca't build and use SHARED libraries in the normal way.
Until we fix this you might be able to get it working by building your renderer library as an executable with the
-sSIDE_MODULElink flag and then adding the resulting wasm file to the link command for the main executable.Hazardu commentedon Sep 6, 2022
target_link_librariesused in CMake does not allow linking executables to executables, so the workaround does not work.However, the solution proposed in #16281 works, and it makes the cmake a whole lot cleaner.
sbc100 commentedon Sep 6, 2022
While
target_link_librariesdoen't work with executables, I think can explicitly add a dependency between one executable and another and then add it to link flags just like any other linker flag.I agree that #16281 would be great in the long term, but if you want something that works to today that isn't an option.