I want to experience with the Lua internals a little bit and affiliate myself with them. I figured digging into the C API would give me some neat knowledge. I wrote up a very small module (parser.dll) in pure C:
#include "parser.h"
#pragma comment(lib, "lua5.4.4.lib")
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
int luaL_parse(lua_State* L) {
const char* path = lua_tostring(L, 1);
const char* cwd = lua_tostring(L, 2);
lua_getglobal(L, "print");
lua_pushstring(L, "Did this run?");
lua_callk(L, 1, 0, 0, NULL);
return 0;
}
static const struct luaL_Reg exports[] = {
{"parse", luaL_parse},
{NULL, NULL}
};
LUAMOD_API int luaopen_parser(lua_State* L) {
luaL_newlib(L, exports);
return 1;
}
Parser.h:
#pragma once
#ifndef lua_h
#include <lua.h>
#include <lauxlib.h>
#endif
int luaL_parse(lua_State* L);
And it compiles successfully. Whenever I try to require it (via require("parser")
), I read this:
lua54.exe: error loading module 'parser' from file 'C:\Users\user\Desktop\Lua\parser.dll':
The specified module could not be found.
I feel like there's more of a mishap in my vs19 project configuration but I don't believe I can dump a text file of that configuration here. If you've any tips, please let me know! I'm not sure how to traverse the problem anymore, I've been attempting to hack at it for a little while.
One detail that may be important is that I'm building with the Lua 5.4.4 source code. As in, I downloaded the source, and just added it as an additional include directory.
On the Lua side, I don't get different results with package.loadlib
either. That gives me nil even with funcname @ "*".
Update, I went through a dependency walker (https://github.com/lucasg/Dependencies) and when I click on the Lua.5.4.4.dll dependency, it says it couldn't be found on the disk. Could the lib file perhaps be messed up? I'm not sure because the program compiles fine still, no unresolved symbols.