lua_open使用luaJIT返回null [英] lua_open returns null using luaJIT
问题描述
使用最近的luaJIT lua_open
返回 null
。这不会发生在普通的lua库中。
lua_State * L = lua_open
std :: cout<< L < std :: endl;
输出: 0x0
我如何让luaJIT工作?
SSCCE:
#include< iostream>
#include< luajit-2.0 / lua.hpp>
//链接库:libluajit-5.1.a
int main(int argc,const char * argv [])
{
lua_State * L = luaL_newstate ); // lua_open();
std :: cout<< L < std :: endl;其他信息:建于OSX 10.9源代码(尝试两个2.0(0),0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) .2和从git)与 make
和 make install
。使用编译器: $ cc --version
Apple LLVM版本5.0(clang-500.2.79) LLVM 3.3svn)
目标:x86_64-apple-darwin13.0.0
线程模型:posix
$ b b
(使用luajit命令行应用程序 luajit
可以正常工作,测试脚本将无错执行。)
解决方案显然,x64 Mac应用程序需要特殊处理;请参阅 http://luajit.org/install.html 。
如果您在OSX上构建一个64位应用程序,直接或间接链接
对LuaJIT,您需要链接您的主可执行文件与以下标志:
-pagezero_size 10000 -image_base 100000000
< blockquote>
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.)
解决方案 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
这篇关于lua_open使用luaJIT返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!