lua_open returns null using luaJIT

折月煮酒 提交于 2019-12-07 01:52:35

问题


Using the recent luaJIT lua_open returns null. This does not happen with the regular lua library.

lua_State *L = lua_open();
std::cout << L << std::endl;

Output: 0x0

How can I get luaJIT to work?

SSCCE:

#include <iostream>
#include <luajit-2.0/lua.hpp>
//linked library: libluajit-5.1.a

int main(int argc, const char * argv[])
{
    lua_State *L = luaL_newstate(); // lua_open();
    std::cout << L << std::endl; // 0x0
}

Additional information: Built on OSX 10.9 from source (tried both 2.0.2 and from git) with make and make install. Using compiler:

$ cc --version
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix

(Using the luajit command line application luajit works fine, a test script gets executed without errors.)


回答1:


Apparently, x64 Mac applications need special handling; see http://luajit.org/install.html.

If you're building a 64 bit application on OSX which links directly or indirectly against LuaJIT, you need to link your main executable with these flags:

-pagezero_size 10000 -image_base 100000000


来源:https://stackoverflow.com/questions/20858911/lua-open-returns-null-using-luajit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!