my first lua program
Posted: Tue Aug 03, 2010 5:00 pm
I'm trying to compile a c++ program that uses lua in gcc and am getting this compile error when I use g++ main.cpp -o test
"main.cpp:27: error: ‘lua_dofile’ was not declared in this scope" any idea on what I'm doing wrong?
"main.cpp:27: error: ‘lua_dofile’ was not declared in this scope" any idea on what I'm doing wrong?
Code: Select all
extern "C"
{
#include <lua5.1/lua.h>
//these includes are in the correct directory
#include <lua5.1/lualib.h>
#include <lua5.1/lauxlib.h>
}
//include the lua libraries. If your compiler doesn't support this pragma
//then don't forget to add the libraries in your project settings!
#pragma comment(lib, "lua.lib")
#pragma comment(lib, "lualib.lib")
#include <iostream>
int main()
{
//create a lua state
lua_State* pL = lua_open();
//enable access to the standard libraries
luaopen_base(pL);
luaopen_string(pL);
luaopen_table(pL);
luaopen_math(pL);
luaopen_io(pL);
if (int error = lua_dofile(pL, "your_first_lua_script.lua") != 0)
{
std::cout << "\n[C++]: ERROR(" << error << "): Problem with lua script file!\n\n" << std::endl;
return 0;
}
//tidy up
lua_close(pL);
return 0;
}