How to install lua-zlib with LuaRocks on Windows?
我已经在Linux环境中用Lua编写了一个程序,它使用Lua模块
时遇到了问题。
我正在使用LuaRocks通过标准命令安装所有其他软件包。因此,要安装
1 2 3 4 5 6 7 8 | 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 |
因此,我在该页面中找到了一个链接,用于Windows下
1 | > luarocks install lua-zlib ZLIB_DIR="C:\\Program Files (x86)\\GnuWin32" |
但同样,另一个错误:
1 2 3 4 5 6 7 8 | 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 |
确实,
注意:如错误日志所示,如果有用,我将
它应该使用静态zlib代替。为此,您可以在Github上遵循此指南。基本上,您需要
已安装功能性zlib库
从https://zlib.net下载,使用
1 | cmake .. -DCMAKE_INSTALL_PREFIX=c:\\lib\\zlib |
然后使用VS中的" Release"构建类型从生成的解决方案中构建INSTALL项目。
下载luarock lua-zlib:
1 2 3 4 | mkdir c:\\lib\\lua-zlib c: cd \\lib\\lua-zlib luarocks download lua-zlib |
编辑您的lua-zlib * .rockspec文件(例如,在c:\\\\ lib \\\\ lua-zlib中),
将
从
到
从本地源安装luarock(更改文件名以匹配现有文件):
1 2 | cd c:\\lib\\lua-zlib luarocks install lua-zlib*.rockspec |