1

I'm having problems while trying to debug Premake5 (https://github.com/premake/premake-core) on macOS Sierra 10.12, using ZeroBrane

I've added the package.cpath and package.path (before calling require('mobdebug').start()) as described in ZeroBrane documentation, but I always have the same error:

Error: error loading module 'socket.core' from file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/socket/core.dylib':
    file is not a bundle

Or, if I re-compile Lua with LUA_USE_DLOPEN I get a different error:

Error: error loading module 'socket.core' from file '/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs/socket/core.dylib':
    dlopen(/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs/socket/core.dylib, 2): Symbol not found: _luaL_prepbuffsize
  Referenced from: /Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs/socket/core.dylib
  Expected in: flat namespace
 in /Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs/socket/core.dylib

Any help available?

Thanks

1 Answers1

2

You seem to be using a version of Lua in Premake that is different from the version that luasocket libraries are compiled for. "file is not a bundle" is a Lua 5.1 message that is shown when the file loader fails to load dynamic library on MacOS with NSObjectFileImageInappropriateFile error. In this case you are loading a library compiled for Lua 5.3 from Lua 5.1 interpreter (/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs53/socket/core.dylib).

In the second case you are actually loading Lua 5.1 library (/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/bin/clibs/socket/core.dylib), but given the error message (Symbol not found: _luaL_prepbuffsize), you seem to be loading it from Lua 5.2 or Lua 5.3 interpreter (as luaL_prefbuffsize was introduced in Lua 5.2).

You should be able to load the module without issues as long as the interpreter you use matches the version of the module you are trying to load.

Paul Kulchenko
  • 25,884
  • 3
  • 38
  • 56
  • Indeed, I've mixed up a bit the things. BTW, I was finally able to have it working with some minor changes to the lua project in Premake. I have defined LUA_USE_DLOPEN, LUA_COMPAT_OPENLIB and LUA_COMPAT_LOADLIB at it works perfectly with ZeroBrane. – Tiziano Sardone May 16 '17 at 05:01