簡體   English   中英

如何在 Windows 上使用 LuaRocks 安裝 lua-zlib?

[英]How to install lua-zlib with LuaRocks on Windows?

我在 Linux 環境中用 Lua 編寫了一個程序,它使用 Lua 模塊ZipWriter及其依賴項( lua-zlibstruct )。 我也在嘗試發布到 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

因此,我在該頁面中找到用於 Windows 的不同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作為編譯器,以防萬一這很有用。

它應該使用靜態 zlib 來代替。 為此,您可以在 Github 上按照本指南進行操作。 基本上,你需要

  1. 已安裝功能性 zlib 庫
    https://zlib.net下載,使用cmake生成 Visual Studio 解決方案(例如在 c:\\lib\\zlib 中)

     cmake .. -DCMAKE_INSTALL_PREFIX=c:\\lib\\zlib

    然后使用 VS 中的“Release”構建類型從生成的解決方案構建 INSTALL 項目。

  2. 下載 luarock lua-zlib:

     mkdir c:\\lib\\lua-zlib c: cd \\lib\\lua-zlib luarocks download lua-zlib
  3. 編輯您的 lua-zlib*.rockspec 文件(例如在 c:\\lib\\lua-zlib 中),將"ZLIB_STATIC"添加到build.modules.zlib.defines ,將platform.windows.modules.zlib.libraries"$(ZLIB_LIBDIR)/zlib""$(ZLIB_LIBDIR)/zlibstatic"

  4. 從本地源安裝 luarock(更改文件名以匹配現有文件名):

     cd c:\\lib\\lua-zlib luarocks install lua-zlib*.rockspec

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM