"env_WASM__XXXX not found in C library imports" during wasm gauge load

Hey,

I’m trying to write a standalone WASM module but since you can’t reload it without restarting the sim I wanted to put my logic in a lib. The lib would be usable from a gauge that I can just throw into any aircraft which can be reloaded with the aircraft selector. The wasm sadly doesn’t compile when loading into the sim and gives the following error:
image
Is there some magic that needs to happen to be able to link against a C++ library from a WASM gauge?
I got the source here if you want to take a look but here’s the gauge code:


The “Implementation” is just a simple class with 2 functions (which work if I copy them to the gauge project directly).

Cheers Jannes

The source you are using appears to rely on SimConnectBridge functionality that you haven’t imported into your project. You are missing an importlib for whatever dll the offending functions reside in. Which come to think of it, you probably aren’t allowed to do from within the WASM sandbox.

Thanks for the reply, that’s the class that’s implemented in the “Implementation” project which I referenced and imported the header from.

Yep, that will be a non-starter. WASM doesn’t allow imports. IIRC, the dll that they generate under the hood from the WASM bytecode is implicitly linked to LoadLibrary and then they explicitly link to the few APIs that they are willing to allow in the sandbox.

That does make sense, but I thought that there’s a way to “fuse” the two project together. The Jetbridge project also has a static lib “Protocol” which does work. Any idea why that would be? I couldn’t find any special sauce in there.

On another note, after trying a few things I found out that the modules actually reload when you replace the file … the more you know … shouldn’t just believe everything you read I guess. That kinda defeats my need for this but now I’m curious :smiley:.

A static lib is just some compiled object code that the linker will add directly into the resulting executable, so I’m not surprised that would work (provided that there are no external dependencies in the code which WASM disallows), given that WASM modules are compiled and linked to a native dll instead of being interpreted or JIT compiled at runtime.

Yeah but mine is also just a static lib. That’s the weird thing and I can’t find any difference.

Dump the dependencies in the static lib. WASM is very limited, so assuming that static libs are allowed, they couldn’t pull in anything that WASM doesn’t support. Even a CRT dependency would be a problem. I would imagine that the default project build settings for a C++ static lib in Visual Studio would likely be problematic.

From my understanding they already are.

That’s a good point. I also tried to copy the lib from Jetbridge over to my project but I can’t seem to get event that to work.

I might try a few more things tomorrow.
Big thanks for the input so far :+1:t2: