I am trying to use Lua in one of my C++ projects, but I get errors:
**** Build of configuration Debug for project MacroLua ****
**** Internal Builder is used for build ****
g++ -LD:\Program Files\Lua\5.1\lib -oMacroLua.exe MainLuaTest.o
MainLuaTest.o: In function `main':
C:/Users/s/MacroLua/MacroLua/Debug/../MainLuaTest.cpp:11: undefined reference to `luaL_newstate'
C:/Users/s/MacroLua/MacroLua/Debug/../MainLuaTest.cpp:14: undefined reference to `luaL_openlibs'
C:/Users/s/MacroLua/MacroLua/Debug/../MainLuaTest.cpp:17: undefined reference to `luaL_loadfile'
C:/Users/s/MacroLua/MacroLua/Debug/../MainLuaTest.cpp:17: undefined reference to `lua_pcall'
C:/Users/s/MacroLua/MacroLua/Debug/../MainLuaTest.cpp:21: undefined reference to `lua_close'
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 864 ms.
I just copied the code from another site:
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
int main()
{
int s=0;
lua_State *L = lua_open();
// load the libs
luaL_openlibs(L);
//run a Lua scrip here
luaL_dofile(L,"foo.lua");
printf("\nI am done with Lua in C++.\n");
lua_close(L);
return 0;
}
I have Lua for Windows installed... What is the problem? :?:
Thanks in advance,
Nick Guletskii.