Reputation: 3
I'm trying to embed lua in a c program, but I'm having problems to compile the code. I have installed everything lua 5.2 related in synaptic and when tried to compile this:
extern "C"{
#include <stdio.h>
#include <string.h>
#include "lua5.2/lua.h"
#include "lua5.2/lauxlib.h"
#include "lua5.2/lualib.h"
}
int main(int argc, char* argv[])
{
lua_State *lua_state;
lua_state = luaL_newstate();
lua_close(lua_state);
}
and compile using
g++ main.cpp -llua
show the folowing errors
Could not find -llua
what do?
Upvotes: 0
Views: 231
Reputation: 14705
There are tools you can use to find the proper compiler / linker switches for a library.
In particular, with a proper installation of the lua5.2 libraries you can use
pkg-config -libs lua5.2
On my system it outputs
-llua5.2
Use this, or the output of pkg-config (backticked) as your linkers argument.
Of course, pkg-config can also tell you the -CFLAGS for the package with
pkg-config --cflags lua5.2
The man page is quite readable.
Upvotes: 1