【发布时间】:2020-05-25 04:12:43
【问题描述】:
我在 Linux 环境中用 Lua 编写了一个程序,它使用 Lua 模块 ZipWriter 及其依赖项(lua-zlib 和 struct)。我也在尝试发布到 Windows,但在构建 lua-zlib 时遇到问题。
我正在使用 LuaRocks 通过标准命令安装所有其他软件包。所以,要安装lua-zlib,我只使用了> luarocks install lua-zlib,但它当然不起作用,因为zlib 本身没有安装,而lua-zlib 是对该库的绑定。
Installing https://luarocks.org/lua-zlib-1.2-0.src.rock
Error: Could not find header file for ZLIB
No file zlib.h in c:/external/include
No file zlib.h in c:/mingw/include
No file zlib.h in c:/windows/system32/include
You may have to install ZLIB in your system and/or pass ZLIB_DIR or ZLIB_INCDIR to the luarocks command.
Example: luarocks install lua-zlib ZLIB_DIR=/usr/local
所以,我在该页面中找到了 a link,用于 Windows 的不同 zlib 下载。我下载了“Complete package, except sources”和“Sources”安装程序,安装它们,他们在C:\Program Files (x86)\GnuWin32目录下创建了文件夹和文件,都与zlib相关。我按照该错误日志提供的示例并尝试再次运行luarocks:
> luarocks install lua-zlib ZLIB_DIR="C:\Program Files (x86)\GnuWin32"
但又是一个错误:
Installing https://luarocks.org/lua-zlib-1.2-0.src.rock
mingw32-gcc -O2 -c -o lua_zlib.o -IC:\lua\luajit lua_zlib.c -DLZLIB_COMPAT -IC:\Program Files (x86)\GnuWin32/include
mingw32-gcc -shared -o zlib.dll lua_zlib.o -lC:\Program Files (x86)\GnuWin32/zlib C:\lua\luajit/lua51.dll -lMSVCRT
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lC:\Program Files (x86)\GnuWin32/zlib
collect2.exe: error: ld returned 1 exit status
Error: Build error: Failed compiling module zlib.dll
确实,C:\Program Files (x86)\GnuWin32/zlib 中没有文件/目录,如错误所示。由于某种原因,它没有安装。我错过了什么?
注意:如错误日志所示,我有mingw32-gcc 作为编译器,以防万一这有用。
【问题讨论】: