-1

I wanted to write a DLL library that integrates into the Lua language for modding one game.

I ran into a problem when I connect the Lua library, everything is fine, but as soon as I start using functions from Lua, the GM 2.0 compiler gives an error 126. I don’t know what the problem is because I compiled the DLL as a 64 bit file and the Lua library is the same comes as a 64 bit file.

Here is the DLL code:

#include "pch.h"
#include <iostream>

#define GMDLL extern "C" __declspec(dllexport)

extern "C"
{
     #include "lua/include/lua.h"
     #include "lua/include/lualib.h" 
     #include "lua/include/lauxlib.h"
 }

     #pragma comment(lib, "lua/liblua54.a")


GMDLL double DLLTest()
{
    lua_State* L = luaL_newstate();

    lua_close(L);

    std::cout << "success" << std::endl;
    return 0;
}

Errors:

LoadLibraryW("PATH_TO_DLL") for function "DLLTest" failed with error code 126 ("The specified module could not be found.")
LoadLibraryW("PATH_TO_DLL") for function "?YYExtensionInitialise@@YAXPEBUYYRunnerInterface@@_K@Z" failed with error code 126 ("The specified module could not be found.")
LoadLibraryW("PATH_TO_DLL") for function "?YYExtensionInitialise@@YA_NPEBUYYRunnerInterface@@_K@Z" failed with error code 126 ("The specified module could not be found.")
LoadLibraryW("PATH_TO_DLL") for function "?YYExtensionInitialise@@YANPEBUYYRunnerInterface@@_K@Z" failed with error code 126 ("The specified module could not be found.")
πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Pyr0Guy
  • 21
  • 3
  • The error message is pretty clear `"The specified module could not be found."` Is there some reason you think that is incorrect? Or are you wanting to understand how DLLs are found? – john Aug 21 '23 at 16:11
  • So GM can't find the Lua library? – Pyr0Guy Aug 21 '23 at 16:20
  • I'm not completely sure but my take was that GM can't find your DLL. The first error occurs when trying to call `DLLTest`. – john Aug 21 '23 at 19:10
  • 1
    What's with `"PATH_TO_DLL"`? Is that you redacting the paths on your system, or is that what the error messages really say? – john Aug 21 '23 at 19:13
  • Im just redact error message, the thing is that path to DLL is right – Pyr0Guy Aug 22 '23 at 07:02
  • If I do not use the LUA functions, then everything is fine – Pyr0Guy Aug 22 '23 at 07:02
  • OK, then I think you were right, the lua DLL (or one of it's dependents) cannot be found. Try running a dependency walker on your DLL. – john Aug 22 '23 at 07:45
  • I connected other Lua files like "lua54.dll" and "liblua54.a" to GM and everything worked. thanks for the help – Pyr0Guy Aug 22 '23 at 12:58

1 Answers1

0

In general, if your DLL depends on another DLL, you'll want to also add that to the extension so that it is exported next to yours.

YellowAfterlife
  • 2,967
  • 1
  • 16
  • 24