#include <iostream>
#include <luabind/luabind.hpp>
#include <luabind/function.hpp>
extern "C"
{
#include "lua5.1/lua.h"
#include "lua5.1/lualib.h"
#include "lua5.1/lauxlib.h"
}
using namespace std;
int main()
{
lua_State* myLuaState = luaL_newstate();
luaL_openlibs( myLuaState );
luabind::open( myLuaState );
int ret = luaL_dofile( myLuaState, "demo1.lua" );
cout << "lalala" << endl;
cout << "Result: " << luabind::call_function<int>( myLuaState, "add", 2, 3 ) << endl;
lua_close( myLuaState );
}
function add(first,second)
return first+second
end
g++ demo1.cc -o demo1 -I /usr/include/lua5.1 -llua5.1 -lluabind
lalala
Result: 5