I'm trying to use srlua
to compile my lua files to executables but I've ran into a problem.
anthony@anthony-linux:~/Downloads/srlua$ make gcc -I/tmp/lhf/lua-5.2.0/src -ansi -pedantic -Wall -Wextra -O2 -c -o srlua.o srlua.c srlua.c:19:17: fatal error: lua.h: No such file or directory compilation terminated. make: *** [srlua.o] Error 1
I'm running linux 64bit (ubuntu)
EDIT: I tried changing the settings of my makefile but now I get this
anthony@anthony-linux:~/Downloads/srlua$ sudo make gcc -I/usr/local/include -ansi -pedantic -Wall -Wextra -O2 -c -o srlua.o srlua.c srlua.c:19:17: fatal error: lua.h: No such file or directory compilation terminated. make: *** [srlua.o] Error 1
I doubt that sudo
will help. The issue is that GCC can't locate lua.h
, which implies that you haven't told it where to find the developer files needed to compile programs that link against the Lua core. You likely need to identify a folder such as /usr/local/lua/include
.
It is also likely that you have the Lua executable package installed, but not the developer package. If so, you will need to locate and install that package. A command like
$ apt-get install liblua5.1-0-dev
does that for Lua 5.1.
If you are building Lua 5.2 from source, then you have all the files you need, you just need to tell srlua's makefile where to find them.
I've successfully built and used srlua on Windows with Lua 5.1, but have not needed to try this on Ubuntu yet, so I can't be a whole lot more specific.
Update:
From your pastebin, try this:
# these will probably work if Lua has been installed globally
LUA= /usr/include/lua5.1
LUAINC= /usr/include/lua5.1
LUALIB= /usr/lib/lua/5.1
LUABIN= /usr/bin
You had typo in the definition of $(LUAINC)
. You will need to locate liblua.a and name the right folder in the definition of $(LUALIB)
. I don't have the lua dev packages installed on my handy Ubuntu box, so I'm not certain where it got put.
Update 2: You are getting closer, since you have got past the compiler configuration and into the linker configuration issues.
On my Ubuntu box, Lua's library appears to be /usr/lib/liblua5.1.a
, and there is no file named liblua.a
. So for me -llua
cannot work. I was able to compile a simplest possible "hello world"...
#include "lua.h"
#include "lauxlib.h"
int main(int argc, char **argv)
{
lua_State *L = luaL_newstate();
luaL_openlibs(L);
luaL_dostring(L, "print('hello, '.._VERSION)");
return 0;
}
with the command
$ gcc -I/usr/include/lua5.1 -o hello hello.c -llua5.1 -lm $ ./hello hello, Lua 5.1 $
Perhaps you should make a similar minimal example work, then go back to tweaking the srlua
makefile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With