lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Lloyd wrote:
I am a lua newbie. This is my first program to print "Hello world" using C API. It gives me runtime error!. Where is the problem?


int main()
    void *ud=NULL;

    lua_State* L=lua_newstate(my_lua_alloc,ud);
        cout<<"Memory allocation error"<<endl;
        return 0;

You need to initialize the Lua libraries here; otherwise, for example, the print() function won't be available.


    int r=lua_load(L,my_lua_reader,ud,"Test Chunk");

[rest snipped]