IssueRaiser

Blazor wasm dynamic linking native sidemodules

### Is there an existing issue for this? - [X] I have searched the existing issues ### Is your feature request related to a problem? Please describe the problem. I am trying to link a C++ library compiled with Emscripten to a Blazor wasm application, and use pinvoke. Thus far, the only way to link the two is to use static linking via `NativeFileReference`, but emcc contains functionality to dynamically link side modules and a main module. Comparing the generated JS in an app where both the lib and main app are written in C++ to one with Blazor Wasm and `NativeFileReference`, it seems that the code responsible for loading the functions into the `Module` object is missing, thus when the app tries to call them when they are uninitialized and `abort` is called and the whole thing breaks. Trying a different approach of statically linking a part of the C++ code containing C wrapper functions that are PInvoked and dynamically linking the C++ class that is wrapped, the same issue happened after the C function reached a function call. ### Describe the solution you'd like `NativeFileReference` other than accepting relocatable wasm files for static linking, would accept native libs compiled with Emscripten's SIDE_MODULE flag and expand the generated javascript to load them at loadtime. ### Additional context https://github.com/Devsh-Graphics-Programming/GPU-With-C-Sharp-Angular-WASM Thus far this app is on the small end, but we are considering making a robust native wasm libra

Posted by Hazardu on Sep 8, 2022, 10:48 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,500 issues0 comments

github (SaaS)

Blazor wasm dynamic linking native sidemodules

HazarduSep 8, 2022, 10:48 AM

### Is there an existing issue for this? - [X] I have searched the existing issues ### Is your feature request related to a problem? Please describe the problem. I am trying to link a C++ library compiled with Emscripten to a Blazor wasm application, and use pinvoke. Thus far, the only way to link the two is to use static linking via `NativeFileReference`, but emcc contains functionality to dynamically link side modules and a main module. Comparing the generated JS in an app where both the lib and main app are written in C++ to one with Blazor Wasm and `NativeFileReference`, it seems that the code responsible for loading the functions into the `Module` object is missing, thus when the app tries to call them when they are uninitialized and `abort` is called and the whole thing breaks. Trying a different approach of statically linking a part of the C++ code containing C wrapper functions that are PInvoked and dynamically linking the C++ class that is wrapped, the same issue happened after the C function reached a function call. ### Describe the solution you'd like `NativeFileReference` other than accepting relocatable wasm files for static linking, would accept native libs compiled with Emscripten's SIDE_MODULE flag and expand the generated javascript to load them at loadtime. ### Additional context https://github.com/Devsh-Graphics-Programming/GPU-With-C-Sharp-Angular-WASM Thus far this app is on the small end, but we are considering making a robust native wasm libra

Comments (0)

No comments yet. Start the discussion.

Comment on this issue