2012-04-28 75 views
1

我無法讓Lua 5.2.0在Xcode 4中工作。我使用鏈接在liblua.a中的make構建它,添加了標題路徑,並將它與Extern "C"一起包含在內。我沒有收到鏈接錯誤。然而,當我運行此代碼:使用Xcode嵌入Lua

#include <iostream> 

extern "C" { 
#include "lua.h" 
#include "lauxlib.h" 
#include "lualib.h" 
} 

int main (int argc, char *argv[]) 
{ 
    lua_State *ls = lua_newstate(0, 0); 

    lua_close(ls); 
    return 0; 
} 

我得到Thread 1: EXC_BAD_ACCESS (code 1, address=0x0)上線11我以爲是告訴我,我事實上是在試圖做出一些不存在的電話。任何幫助將不勝感激!

感謝, 馬克

回答

3

你傳遞一個NULL內存分配函數lua_newstate。難怪它崩潰。也許你想用luaL_newstate

+0

我正式覺得自己像個白癡。謝謝! – Sparky 2012-04-28 15:48:18