Code: Select all
love.app/Contents/Framework/Lua.framework/Versions/A/Lua
Or, if you don't want to recompile: First make sure that your dylib file loads fine with the standard luajit distribution. Then replace the "Lua" file buried in
Code: Select all
love.app/Contents/Framework/Lua.framework/Versions/A/Lua
----------------------------------------------------------------------------------
After some work to pin down the problem, I made a minimal example for this.
I wrote a small C library, almost a direct copy of the example in the book Programming in Lua.
Code: Select all
#include "lauxlib.h"
#include "lua.h"
#include "lualib.h"
#include <math.h>
static int l_sin (lua_State *L) {
double d = luaL_checknumber(L, 1); /* get argument */
lua_pushnumber(L, sin(d)); /* push result */
return 1; /* number of results */
}
static const struct luaL_reg mylib [] = {
{"sin", l_sin},
{NULL, NULL} /* sentinel */
};
int luaopen_mylib (lua_State *L) {
luaL_openlib(L, "mylib", mylib, 0);
return 1;
}
Next, a miniature lua script ("main.lua") in the same directory:
Code: Select all
l = package.loadlib("hw.dylib", "luaopen_mylib")
a = l()
print(a.sin(1))
Code: Select all
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 hw.dylib 0x0000000008a36aa3 lua_pushvalue + 195
1 hw.dylib 0x0000000008a4f10c luaL_findtable + 28
2 hw.dylib 0x0000000008a4efcb luaL_openlib + 91
3 hw.dylib 0x0000000008a362c5 luaopen_mylib + 37
4 LuaJIT.LuaJIT 0x0000000101f8be56 0x101f89000 + 11862
Can anyone provide a clue to why this is happening, and a pointer to some possible solutions? Any help is appreciated!
Although it works, I haven't yet investigated further. I think the answer lies in the makefile in https://github.com/slime73/love-apple-dependencies.