2

Hey I'm trying to load a Lua file into my c++ project but there are some errors I don't know how to fix... I have downloaded the libraries from Lua and I've got them in my include folder. The dll's are in my project and the libs are on the lib folder of my compiler so it shouldn't be a linker error.

The errors I'm getting are:

error: 'luaL_newstate' was not declared in this scope
error: 'luaL_openlibs' was not declared in this scope
error: 'luaL_dofile' was not declared in this scope

I have no idea what to do. I'm using codeblocks and I'm using this linker argument: -llua5.1

Here is my code:

lua_State *L = lua_open();
luaL_openlibs(L);

luaL_dofile(L,"ModificarViento.lua");

lua_getglobal(L,"MueveFlecha");

lua_call(L,0,2);

vientoX = (int)lua_tointeger(L,-2);
vientoX = (int)lua_tointeger(L,-1);
lua_pop(L,1);

lua_close(L);

and here are my includes of Lua

extern "C"{
    #include <lua.h>
    #include <lualib.h>
    #include <lauxlib.h>
}

If anyone knows what's wrong, please tell me.

Thank you very much!

2
  • Those are compiler errors, not linker errors. It seems like you're not including lauxlib.h, but you are. Can you show all of your code, rather than two sections of it? Commented Jul 8, 2011 at 5:16
  • As a hint for the future: please use decent English spelling, and avoid stuff like lolz, plz, etc. Aside of being a pleasure to read, it'll get you more answers to your questions. Commented Jan 2, 2012 at 16:06

1 Answer 1

1

I fixed it. I downloaded Lua for mingw32. I had the VC++ version. Oh well

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.