storen
storen

Reputation: 1035

libluajit-5.1.so.2:cann't open shared object file:No such file or directory

I want to test luajit's c api on my hosts,following is my code:

#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;
}

Then I compile it with gcc:

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

But when I run it

$ ./test_lua

it prompts that,

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

Somebody know how to solve it?

Upvotes: 1

Views: 8946

Answers (1)

xpfans
xpfans

Reputation: 91

set up LD_LIBRARY_PATH variable, make it reference to libluajit-5.1.so.2 live directory.

cmd:

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

Upvotes: 5

Related Questions