Reputation: 621
I've written a program with Lua, in a Linux environment, and it uses the Lua module ZipWriter
and its dependecies (lua-zlib
and struct
). I'm trying to release to Windows as well, but I'm having trouble building lua-zlib
.
I'm using LuaRocks to install all other packages, with standard commands. So, to install lua-zlib
, I just used > luarocks install lua-zlib
, but of course it wouldn't work, as zlib
itself wasn't installed, and lua-zlib
is a binding to that library.
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
So, I found a link in that page for different downloads of zlib
for Windows. I downloaded both the "Complete package, except sources" and "Sources" Setups, installed them, and they created folders and files under the directory C:\Program Files (x86)\GnuWin32
, all related to zlib
. I followed the example provided by that error log and tried running luarocks
again:
> luarocks install lua-zlib ZLIB_DIR="C:\Program Files (x86)\GnuWin32"
But again, another error:
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
And indeed, there was no file/directory in C:\Program Files (x86)\GnuWin32/zlib
, as the error shows. For some reason, that was not installed. What am I missing?
Note: as the error log shows, I have mingw32-gcc
as the compiler, in case this is useful.
Upvotes: 3
Views: 1720
Reputation: 716
2024 Manual
In this manual I will describe the way to install ZipWriter from the first to the last step. It will include lua + luarocks download and screenshots. ZipWriter supports lzlib
rock which doesn't require manual library compilation.
You will need Git Bash (installed with Git automatically).
This guide doesn't work on PowerShell.
Make sure you install 32bit version.
lua_modules
if exists.luarocks
if exists.luarocks
in %UserProfile%
dir if exists.gitignore
file ends with new empty linePATH
variableC:\lua
(to suit this guide)lua-5.3.x_Win32_bin.zip
and lua-5.3.x_Sources.zip
where x
is the latest patch version from https://luabinaries.sourceforge.net/download.htmli686-14.2.0-release-win32-dwarf-msvcrt-rt_v12-rev0.7z
for dependencies compilation from https://github.com/niXman/mingw-builds-binaries/releases (link source https://www.mingw-w64.org/downloads/)PATH
variable:C:\lua
C:\lua\mingw32\bin
C:\lua\mingw32\i686-w64-mingw32\bin
luarocks config lua_version 5.3
luarocks config variables.LUA_INCDIR "C:\lua\lua53\include"
luarocks init
luarocks install lzlib ZLIB_DIR="C:\lua\mingw32\i686-w64-mingw32"
luarocks install zipwriter
Further usage:
./lua.bat your_script.lua
Upvotes: 1
Reputation: 19000
It should work using a static zlib instead. To do so, you can follow this guide on Github. Basically, you need
Functional zlib library installed
Download from https://zlib.net , use cmake
to generate Visual Studio solution (e.g. in c:\lib\zlib)
cmake .. -DCMAKE_INSTALL_PREFIX=c:\lib\zlib
then build the INSTALL project from the resulting solution, using 'Release' build type in VS.
Download luarock lua-zlib:
mkdir c:\lib\lua-zlib
c:
cd \lib\lua-zlib
luarocks download lua-zlib
Edit your lua-zlib*.rockspec file (e.g. in c:\lib\lua-zlib),
add , "ZLIB_STATIC"
to build.modules.zlib.defines
,
change platform.windows.modules.zlib.libraries
from "$(ZLIB_LIBDIR)/zlib"
to "$(ZLIB_LIBDIR)/zlibstatic"
Install the luarock from local source (change the filename to match the existing one):
cd c:\lib\lua-zlib
luarocks install lua-zlib*.rockspec
Upvotes: 1