I am trying to compile a c++ program that uses lua. The compiler I am using mingw, under ubuntu.
In console I type "g++ -o test main.cpp -llua -ldl". This returns:
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: In function ‘int main()’:
main.cpp:10: error: ‘lua_State’ was not declared in this scope
main.cpp:10: error: ‘L’ was not declared in this scope
main.cpp:10: error: ‘lua_open’ was not declared in this scope
main.cpp:11: error: ‘luaL_openlibs’ was not declared in this scope
main.cpp:12: error: ‘luaL_dofile’ was not declared in this scope
main.cpp:13: error: ‘printf’ was not declared in this scope
main.cpp:14: error: ‘lua_close’ was not declared in this scope
As far as I know, your C++ and Lua code is fine.
I'm not an expert on Lua or using it with Ubuntu and compiling from the command line, but it looks like it cannot find the lua files:
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
/tmp/cciDcRBV.o: In function `main':
main.cpp:(.text+0x12): undefined reference to `luaL_newstate'
main.cpp:(.text+0x22): undefined reference to `luaL_openlibs'
main.cpp:(.text+0x36): undefined reference to `luaL_loadfile'
main.cpp:(.text+0x5e): undefined reference to `lua_pcall'
main.cpp:(.text+0x78): undefined reference to `lua_close'
collect2: ld returned 1 exit status
I am thinking that I installed something incorrectly
So this is what happened, I originally installed lua through synaptic, I then uninstalled and installed the binaries on the lua website, I then typed in what combatant936 told me to, and it said it couldn't find -llualib, and I noticed that the l was undercase, so I typed g++ -o test main.cpp -llua -ldl, and it magically worked. Thanks for the help everyone
Last edited by Randi on Sat Apr 24, 2010 3:09 pm, edited 2 times in total.