ZequeZ
August 16th, 2010, 09:23 PM
Well, I was wondering how to embed a scripting language into C++ so I did a search and I find out this tutorial (http://www.debian-administration.org/articles/264), I installed the required libraries and anything that said LUA and DEV in Synaptics... But, I can't manage to compile it...
Here is the code from the tutorial:
#include <stdio.h>
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h" /* the Lua interpreter */
lua_State* L;
int main ( int argc, char *argv[] ) {
/* initialize Lua */
L = lua_open();
/* load various Lua libraries */
lua_baselibopen(L);
luaopen_table(L);
luaopen_io(L);
luaopen_string(L);
luaopen_math(L);
/* cleanup Lua */
lua_close(L);
return 0;
}
First of all: Why it uses #include "***" instead of #include <***>? It want me to copy the headers from the system libraries to my program path? :S. Anyway if I change it to <***> it doesn't find anything neither:
zequez@zequez-desktop:$ gcc main.cpp
main.cpp:3:17: error: lua.h: No such file or directory
main.cpp:4:20: error: lualib.h: No such file or directory
main.cpp:5:21: error: lauxlib.h: No such file or directory
main.cpp:8: error: expected constructor, destructor, or type conversion before ‘*’ token
main.cpp: In function ‘int main(int, char**)’:
main.cpp:12: error: ‘L’ was not declared in this scope
main.cpp:12: error: ‘lua_open’ was not declared in this scope
main.cpp:15: error: ‘lua_baselibopen’ was not declared in this scope
main.cpp:16: error: ‘luaopen_table’ was not declared in this scope
main.cpp:17: error: ‘luaopen_io’ was not declared in this scope
main.cpp:18: error: ‘luaopen_string’ was not declared in this scope
main.cpp:19: error: ‘luaopen_math’ was not declared in this scope
main.cpp:22: error: ‘lua_close’ was not declared in this scope
zequez@zequez-desktop:$
Which are the links for LUA? And what means the return of lua-config?
Here is the code from the tutorial:
#include <stdio.h>
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h" /* the Lua interpreter */
lua_State* L;
int main ( int argc, char *argv[] ) {
/* initialize Lua */
L = lua_open();
/* load various Lua libraries */
lua_baselibopen(L);
luaopen_table(L);
luaopen_io(L);
luaopen_string(L);
luaopen_math(L);
/* cleanup Lua */
lua_close(L);
return 0;
}
First of all: Why it uses #include "***" instead of #include <***>? It want me to copy the headers from the system libraries to my program path? :S. Anyway if I change it to <***> it doesn't find anything neither:
zequez@zequez-desktop:$ gcc main.cpp
main.cpp:3:17: error: lua.h: No such file or directory
main.cpp:4:20: error: lualib.h: No such file or directory
main.cpp:5:21: error: lauxlib.h: No such file or directory
main.cpp:8: error: expected constructor, destructor, or type conversion before ‘*’ token
main.cpp: In function ‘int main(int, char**)’:
main.cpp:12: error: ‘L’ was not declared in this scope
main.cpp:12: error: ‘lua_open’ was not declared in this scope
main.cpp:15: error: ‘lua_baselibopen’ was not declared in this scope
main.cpp:16: error: ‘luaopen_table’ was not declared in this scope
main.cpp:17: error: ‘luaopen_io’ was not declared in this scope
main.cpp:18: error: ‘luaopen_string’ was not declared in this scope
main.cpp:19: error: ‘luaopen_math’ was not declared in this scope
main.cpp:22: error: ‘lua_close’ was not declared in this scope
zequez@zequez-desktop:$
Which are the links for LUA? And what means the return of lua-config?