0

How do you build wxLua on Mac OS X (10.6.8) so that it uses LuaJIT2 instead of the standard Lua interpreter?

I have tried:

./configure --with-lua-prefix=/Users/finnw/LuaJIT-2.0.0-beta9

where /Users/finnw/LuaJIT-2.0.0-beta9 is the directory in which I built LuaJIT.

I have also tried copying src/libluajit.a to lib/liblua5.1.a and src/libluajit.so to lib/liblua5.1.so and various other combinations such as changing the extension from .so to .dylib

But still I always get Lua not LuaJIT (as can be verified by loading a script that requires the ffi module.)

How can I force it to link against LuaJIT2? And why does the configure --with-lua-prefix option not do what it claims to do?

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
finnw
  • 47,861
  • 24
  • 143
  • 221

1 Answers1

1

The following works on Debian:

$ ./configure --with-lua-prefix=/path/to/luajit --enable-systemlua

which points at /path/to/luajit/include/lua5.1/*.h and /path/to/luajit/lib/liblua5.1.a.

--enable-systemlua ensures that it tries to find Lua at the prefix you specify, and will make configure fail rather than fall back on the Lua bundled with wxLua.

You'll also need to replace the two instances of luaI_openlib in wxlbind.cpp and wxlstate.cpp with luaL_openlib, as this is deprecated in 5.1 and not present in LuaJIT2.

furq
  • 5,648
  • 3
  • 16
  • 21
  • I am already using `--with-lua-prefix`. Adding `--enable-systemlua` makes no difference for me. – finnw Jul 11 '12 at 15:56
  • Are your LuaJIT headers in /path/to/luajit/include/lua5.1? It wouldn't work for me if the headers were just in include/. – furq Jul 11 '12 at 20:06
  • I think this is on the right track, as I am now getting errors about `luaI_openlib` not being found, which suggests the correct headers are being included – finnw Jul 11 '12 at 21:19
  • Replace the two references to luaI_openlib with luaL_openlib, and you should be home and dry. – furq Jul 12 '12 at 02:35
  • Now I have a different error: `Incompatible library version: libwxlua_macu_wxbindxrc-2.8.0.dylib requires version 51.0.0 or later, but liblua-51.2.dylib provides version 2.0.0` – finnw Jul 12 '12 at 08:46
  • Can you build the apps with --disable-shared passed to configure? – furq Jul 12 '12 at 09:45
  • 1
    @finnw, I'm guessing `liblua-51.2.dylib` is actually renamed from `luajit-2.0.0.dylib`. Try using [`install_name_tool`](https://developer.apple.com/library/mac/#documentation/Darwin/Reference/Manpages/man1/install_name_tool.1.html) to change the library dependency of `libwxlua_macu_wxbindxrc-2.8.0.dylib` to your `luajit-2.0.0.dylib`. – tony19 Jul 12 '12 at 15:16