Linux srlua makefile 错误 lua.h 没有那个文件或目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20079572/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 01:23:43  来源:igfitidea点击:

srlua makefile error lua.h No such file or directory

linuxcompiler-errorsluamakefile

提问by Anthony

I'm trying to use srluato compile my lua files to executables but I've ran into a problem.

我正在尝试将srlua我的 lua 文件编译为可执行文件,但遇到了问题。

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)

我正在运行 64 位 linux (ubuntu)

EDIT: I tried changing the settings of my makefile but now I get this

编辑:我尝试更改我的 makefile 的设置,但现在我明白了

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

采纳答案by RBerteig

I doubt that sudowill 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.

我怀疑这sudo会有所帮助。问题是 GCC 找不到lua.h,这意味着您没有告诉它在哪里可以找到编译链接到 Lua 核心的程序所需的开发人员文件。您可能需要确定一个文件夹,例如/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

您也可能安装了 Lua 可执行包,但没有安装开发人员包。如果是这样,您将需要找到并安装该软件包。像这样的命令

$ apt-get install liblua5.1-0-dev

does that for Lua 5.1.

为 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.

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

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.

我已经使用 Lua 5.1 在 Windows 上成功构建和使用了 srlua,但还不需要在 Ubuntu 上尝试这个,所以我不能说得更具体了。

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.

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

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

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

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 -lluacannot work. I was able to compile a simplest possible "hello world"...

在我的 Ubuntu 机器上,Lua 的库似乎是/usr/lib/liblua5.1.a,并且没有名为liblua.a. 所以对我来说-llua不能工作。我能够编译一个最简单的“你好世界”......

#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 srluamakefile.

也许您应该制作一个类似的最小示例,然后返回调整srluamakefile。