Emscripten Resolve Header Problem

Adam Crockett 🌀 - Oct 2 '20 - - Dev Community

Background

I am trying to build Lua 5.4.0 for WASM running in node.js using emscripten.

In the past I have successfully done this with the old emacripten backend and c++ using a Lua wrapper (sol) but I didn't really learn anything with this abstraction, also I would prefer to write C.

Problem

For some reason I have had little success getting the headers to resolve. Here are the compiler flags in use (ran from shell in JavaScript).

Now I can compile a basic hello world but adding the headers, emacripten complains of unknown symbol luaL_newstate 🤷‍♂️, I have a liblua.a built from Lua src, I have -I and -L.

Anything obvious standing out?
Ive been trying things for days and searching all over with limited success.

[
  '/Users/adam.crockett/Code/typescript/tidal-node/src/backend/c/main.c',
  '-o /Users/adam.crockett/Code/typescript/tidal-node/target/tidal-node-glue.js',
  '-fcolor-diagnostics',
  '-s WASM=1',
  '-s ENVIRONMENT=node',
  '-I/Users/adam.crockett/Code/typescript/tidal-node/ops/tmp/lua-5.4.0/src',
  '-L/Users/adam.crockett/Code/typescript/tidal-node/ops/tmp/lua-5.4.0/src',
  '-lliblua',
  `-s EXPORTED_RUNTIME_METHODS='["ccall","cwrap","UTF8ToString"]'`,
  `-s "EXPORTED_FUNCTIONS=['_main', '_do_string']"`
]
Enter fullscreen mode Exit fullscreen mode

main.c

#include <stdio.h>
#include <string.h>

//#include <emscripten.h>
#include "lua.h" // wont resolve
#include "lauxlib.h" // wont resolve
#include "lualib.h" // wont resolve


int main()
{
    return 0;
}

int do_string(const int *script)
{
    lua_State *L = luaL_newstate();
    return 0;
}
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .