开发者

Lua - initializing [duplicate]

This question already has answers here: What is an undefined reference/unresolved external symbol error and how do I fix it? (38 answers) Closed 8 years ago. 开发者_开发问答

I can't init lua correctly under Arch Linux. Lua - latest version. Here is my code:

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

int main()
{
    lua_State *luaVM = luaL_newstate();
    if (luaVM == NULL)
    {
        printf("Error initializing lua!\n");
        return -1;
    }

    luaL_openlibs(luaVM);
    lua_close(luaVM);

    return 0;
}

/tmp/cc0iJ6lW.o: In function main': test_lua.cpp:(.text+0xa): undefined reference toluaL_newstate'

test_lua.cpp:(.text+0x34): undefined reference to `luaL_openlibs'

test_lua.cpp:(.text+0x40): undefined reference to `lua_close' collect2: ld

returned 1 exit status

What's wrong?


You need to link with the Lua library by passing the -llua and -llualib flags.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜