我在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因此,我在页面中找到了一个链接,用于zlib的不同下载。我下载了“完整包,除了源代码”和“源”设置,安装了它们,它们在目录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作为编译器,以防这是有用的。
发布于 2020-02-10 02:08:34
它应该使用静态的zlib来代替。要做到这一点,您可以在Github上跟踪这个指南。基本上,你需要
cmake生成Visual解决方案(例如在c:\lib\zlib中)
制造..。-DCMAKE_INSTALL_PREFIX=c:\lib\zlib
然后使用VS中的“Release类型”从结果解决方案构建安装项目。"ZLIB_STATIC"到build.modules.zlib.defines,将platform.windows.modules.zlib.libraries从"$(ZLIB_LIBDIR)/zlib"更改为"$(ZLIB_LIBDIR)/zlibstatic"https://stackoverflow.com/questions/60140305
复制相似问题