luasocket.c:20:17: 错误:找不到lua.h文件或目录。

4

我正在为Lua安装luasocket模块,但是我收到了以下错误信息:

[root@localhost local]# wget http://files.luaforge.net/releases/luasocket/luasocket/luasocket-2.0.2/luasocket-2.0.2.tar.gz
[root@localhost local]# tar zxvf luasocket-2.0.2.tar.gz
[root@localhost local]# cd luasocket-2.0.2
[root@localhost luasocket-2.0.2]# make && make install
cd src; make all
make[1]: Entering directory `/usr/local/luasocket-2.0.2/src'
gcc  -DLUASOCKET_DEBUG  -pedantic -Wall -O2 -fpic   -c -o luasocket.o luasocket.c
luasocket.c:20:17: error: lua.h: No such file or directory
luasocket.c:21:21: error: lauxlib.h: No such file or directory
luasocket.c:24:24: error: compat-5.1.h: No such file or directory
In file included from luasocket.c:30:
luasocket.h:30: error: expected ‘)’ before ‘*’ token
In file included from luasocket.c:31:
auxiliar.h:37: error: expected ‘)’ before ‘*’ token
auxiliar.h:38: error: expected ‘)’ before ‘*’ token
auxiliar.h:39: error: expected ‘)’ before ‘*’ token
auxiliar.h:40: error: expected ‘)’ before ‘*’ token
auxiliar.h:41: error: expected ‘)’ before ‘*’ token
auxiliar.h:42: error: expected ‘)’ before ‘*’ token
auxiliar.h:43: error: expected ‘)’ before ‘*’ token
auxiliar.h:44: error: expected ‘)’ before ‘*’ token
auxiliar.h:45: error: expected ‘)’ before ‘*’ token
auxiliar.h:46: error: expected ‘)’ before ‘*’ token
In file included from luasocket.c:32:
except.h:33: error: expected ‘)’ before ‘*’ token
In file included from luasocket.c:33:
timeout.h:19: error: expected ‘)’ before ‘*’ token
timeout.h:26: error: expected ‘)’ before ‘*’ token
In file included from luasocket.c:34:
buffer.h:39: error: expected ‘)’ before ‘*’ token
buffer.h:41: error: expected ‘)’ before ‘*’ token
buffer.h:42: error: expected ‘)’ before ‘*’ token
buffer.h:43: error: expected ‘)’ before ‘*’ token
buffer.h:44: error: expected ‘)’ before ‘*’ token
In file included from luasocket.c:35:
inet.h:27: error: expected ‘)’ before ‘*’ token
inet.h:35: error: expected ‘)’ before ‘*’ token
inet.h:36: error: expected ‘)’ before ‘*’ token
In file included from luasocket.c:36:
tcp.h:34: error: expected ‘)’ before ‘*’ token
In file included from luasocket.c:37:
udp.h:31: error: expected ‘)’ before ‘*’ token
In file included from luasocket.c:38:
select.h:15: error: expected ‘)’ before ‘*’ token
luasocket.c:43: error: expected ‘)’ before ‘*’ token
luasocket.c:44: error: expected ‘)’ before ‘*’ token
luasocket.c:45: error: expected ‘)’ before ‘*’ token
luasocket.c:50: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘mod’
luasocket.c:60: warning: ISO C does not allow extra ‘;’ outside of a function
luasocket.c:62: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘func’
luasocket.c:66: warning: ISO C does not allow extra ‘;’ outside of a function
luasocket.c:71: error: expected ‘)’ before ‘*’ token
luasocket.c:80: error: expected ‘)’ before ‘*’ token
luasocket.c:89: error: expected ‘)’ before ‘*’ token
luasocket.c:113: error: expected ‘)’ before ‘*’ token
make[1]: *** [luasocket.o] Error 1
make[1]: Leaving directory `/usr/local/luasocket-2.0.2/src'
make: *** [all] Error 2

有人可以帮我吗?谢谢提前 :)


lua.h 是 Lua C 源代码的主头文件。要么您没有安装 Lua 源代码,要么您没有告诉编译器在哪里找到它。 - Roddy
2个回答

5

您需要设置LUAINC

由于您没有指定使用的操作系统,我无法给出明确答案以设置其值。在Debian上,如果您想要为Lua5.1构建,请将其设置为-I/usr/include/lua5.1/

您可以通过编辑config(从makefile中包含)或在命令行上指定来设置该变量:

$ make LUAINC=-I/usr/include/lua5.1/

0

推荐的解决方案在我使用Alpine 3.4时无法正常工作。为了使其在这个环境中工作,我不得不下载该软件包并进行以下修改。

luasec-luasec-0.6/src/luasocket/usocket.h

 /* TODO: ifdef the ALPINE #include <sys/poll.h> */
 #include <poll.h>

然后修改Makefile文件

# Inform the location to install the modules
LUAPATH  ?= /usr/local/share/lua/5.1
LUACPATH ?= /usr/local/lib/lua/5.1


# Edit the lines below to inform new path, if necessary.
# Path below points to internal LuaSocket's help files.
LUAINCDIR = -I/usr/local/api-gateway/luajit/include/luajit-2.1
INC_PATH ?= -I/usr/include
LIB_PATH ?= -L/usr/lib
INCDIR    = -I. $(LUAINCDIR) $(INC_PATH)       <------ include new path
LIBDIR    = -L./luasocket $(LIB_PATH)

希望这可以帮助其他遇到这个特定问题的人。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接