lua-users home
lua-l archive

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

On Fri, Sep 15, 2006 at 04:01:22PM -0300, Ricardo Sarmento wrote:
> If I use the correct syntax:
> lua_State *L=luaL_newstate();
> I get the follow error:
> /root/Ricardo/Outros/Lua/Kdevelop/teste/src/main.cpp:80: undefined reference to `luaL_newstate'
Are you really developing s/w as the root user? You may come to regret
that if you do.

> It seems like I haven't linked the correct library, but if I use the wrong syntax:
> lua_State *L=luaL_newstate("something");
> I get the follow error:
> /usr/local/include/lauxlib.h:82: error: too many arguments to function â??lua_State* luaL_newstate()â??
> Then, I'm confuse: If the library is wrongly linked, gcc wouldn't know how much arguments are asked by luaL_newstate, right?

No, c compilers find out how many args are expected from the headers,
and /usr/local/include is in your header search path, so luaxlib.h is
found. But the header doesn't tell it the library name.

You need to link the lua library that defines luaL_newstate. On my
system 5.0 and 5.1 are both installed:

% ls /usr/lib/liblua*.a

For 5.0, I would have to add -llua50 and -llualib50 to my link flags.
For 5.1, I would just add -llua5.1.

The name used for the lua libs varies a lot across platforms, you'll
have to look to see what they are called on your box.