|
Hi, I'm relatively new to Lua and looking to use it as a scripting extension in a high frequency real-time application. I hope to use LuaJIT as opposed to the interpreter to get the extra performance I need. I am using Snow Leopard (64 bit mode) on a Xeon with gcc 4.2.1. I've been unable to get luajit to work properly when embedded, receiving a SEGV on either LuaJit-2.0.0-beta5 or a build off of the git HEAD. The test program is as follows: #include <stdio.h> #include <lua.hpp> int main(int argc, char** argv) { // Create a new lua state lua_State *L = lua_open(); luaL_openlibs(L); // Now use this class in a lua script luaL_dostring(L, "function f(x)\n" " return x*x\n" "end\n" "sum = 0\n" "for i=1,10000 do\n" " sum = sum + f(i)\n" "end\n" "print (sum)\n" ); lua_close(L); } Building with the interpreted g++ -g -I../../lib/include/ -I../../lib/include/lua -L../../lib/macos -L/usr/local/lib -llua5.1 basic.cpp -o basic Building with LuaJIT g++ -g -I../../lib/include/ -I../../lib/include/lua -L../../lib/macos /usr/local/lib/libluajit-5.1.a basic.cpp -o basic The former executes as expected and the later (with LuaJIT) consistently fails with a SEGV. Running in gdb indicates: Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000004 0x00000001000370d8 in lj_alloc_malloc () Ideas? I don't believe I can use LuaJIT-1.1.6 as does not appear to have 64bit support? Thanks Jonathan |