libluajit-5.1.so.2:无法打开共享对象文件:没有那个文件或目录。

我想在我的主机上测试 luajit 的 c api,以下是我的代码:

#include <stdio.h>
#include <luajit.h>
#include <lualib.h>
#include <lauxlib.h>

int main()
{
    lua_State *L;
    L=luaL_newstate();
    luaL_openlibs(L);
    lua_pushnumber(L,10);
    lua_pushstring(L,"hello");
    lua_pushboolean(L,0);
    lua_close(L);
    //printf("luatop:%d\n",lua_gettop(L));
    return 0;
}

然后我用 gcc 编译它:

gcc -I /usr/local/include/luajit-2.0/ -lluajit-5.1 test_lua.c -o test_lua

但当我运行它时

$ ./test_lua

它提示,

./test_lua: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory

有人知道怎么解决吗?

点赞
用户3226707
用户3226707

设置 LD_LIBRARY_PATH 变量,使其引用 libluajit-5.1.so.2 的动态链接库所在目录。

命令:

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
2016-04-18 01:46:33