srlua makefile错误lua.h没有这样的文件或目录 [英] srlua makefile error lua.h No such file or directory

查看:483
本文介绍了srlua makefile错误lua.h没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用srlua将lua文件编译为可执行文件,但是遇到了问题.

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

我正在运行Linux 64位(ubuntu)

I'm running linux 64bit (ubuntu)

我尝试更改我的Makefile的设置,但是现在我明白了

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

推荐答案

我怀疑sudo是否会有所帮助.问题是GCC找不到lua.h,这意味着您没有告诉它在哪里可以找到编译与Lua核心链接的程序所需的开发人员文件.您可能需要标识一个文件夹,例如/usr/local/lua/include.

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.

也可能已安装Lua可执行程序包,但未安装开发人员包.如果是这样,您将需要找到并安装该软件包.像

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

对于Lua 5.1做到了这一点.

does that for Lua 5.1.

如果要从源代码构建Lua 5.2,则您拥有了所需的所有文件,只需告诉srlua的makefile在哪里可以找到它们.

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.

我已经在带有Lua 5.1的Windows上成功构建并使用了srlua,但是还不需要在Ubuntu上进行尝试,因此我不能再具体很多了.

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.

更新:

在您的pastebin中,尝试以下操作:

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

您在$(LUAINC)的定义中有错字.您将需要找到liblua.a,并在$(LUALIB)的定义中命名正确的文件夹.我没有在方便的Ubuntu盒子上安装lua dev软件包,所以我不确定它放在哪里.

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.

更新2:,您越近越好,因为您已经越过了编译器配置并进入了链接器配置问题.

Update 2: You are getting closer, since you have got past the compiler configuration and into the linker configuration issues.

在我的Ubuntu盒子上,Lua的库似乎是/usr/lib/liblua5.1.a,并且没有名为liblua.a的文件.所以对我来说-llua无法工作.我能够编译出一个最简单的"hello world" ...

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;
}

使用命令


$ gcc -I/usr/include/lua5.1 -o hello hello.c -llua5.1 -lm
$ ./hello
hello, Lua 5.1
$

也许您应该进行类似的最小示例工作,然后返回调整srlua makefile.

Perhaps you should make a similar minimal example work, then go back to tweaking the srlua makefile.

这篇关于srlua makefile错误lua.h没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆