Closed twelvee closed 7 months ago
I have added support for this: https://github.com/metacall/core/commit/203a3e79c57d75bb2b7e3599bd65da64ced9d303
I am going to update node in windows, tag a new version and update the distributable, once it's done, could you confirm it works?
🐛 Bug Report
The problem is in the initialization of metacall in the embedded environment. All paths are set correctly, but metacall cannot initialize and crashes with code 126 and the following log
Failed to load: *correct_absolute_path*\node_loader.dll with error code [126]
The problem is due to the fact that the executable is not in the same directory, so we can't get the correct path to the libnode.dll file.
Expected Behavior
All paths are set correctly, metacall should have initialized successfully.
Current Behavior
We get a rather strange error that can be misleading. The file exists, but the error 126 not found.
Possible Solution
We can use SetDllDirectoryA(); to set the correct path to the lib folder where all the dll files needed for metacall are located.
Tested by calling this method before initializing metacall:
SetDllDirectoryA(std::filesystem::absolute("../../metacall/lib").string().c_str());
after which we call
metacall_initialize()
and metacall is successfully initialized.Steps to Reproduce
I'm working on a rather unique case study - embedding metacall inside a Source2 game server. So the steps for reproduce are not exactly the same as I used, but I think it will work just as well.
metacall_initialize
andmetacall_load_from_file
Context (Environment)
executable located:
E:\cs2\server\game\bin\win64\cs2.exe
metacall libraries (including metacall.dll) located:E:\cs2\server\game\csgo\addons\resourcemod\bin\metacall
resourcemod (a dll file that I inject into a game and it runs metacall) located:E:\cs2\server\game\csgo\addons\resourcemod\bin\
loader: node