I’m having trouble building one of my cabal projects, receiving this build error from cabal:
Failed to build zlib-0.7.1.0. The failure occurred during the configure step.
Build log (
/home/ola/.cache/cabal/logs/ghc-9.4.8/zlib-0.7.1.0-ea2ccc2f93d951d84a88c78a7b4f196fea6a3780cdafe6f13025c03d6aaa9dce.log
):
Configuring library for zlib-0.7.1.0..
Error: .cabal-wrapped: Missing dependency on a foreign library:
* Missing (or bad) header file: zlib.h
* Missing (or bad) C library: z
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags...
I have tried installing zlib and variations, but that hasn’t worked. I figured something could have changed, and sure enough in April this happened:
0.7.1.0 Bodigrim andrew.lelechenko@gmail.com April 2024
Split zlib C sources into zlib-clib package (thanks @hasufell).
Use zlib-clib on Windows, unless pkg-config is available.
So something that might be worth testing is to use an older version, but since the project is only indirectly depending on zlib, how do I pinpoint an earlier version in my .cabal?
It could be worth mentioning that I switched to NixOS some time ago.
I’m not sure what’s up with your environment. While there were changes to Windows setup in the recent zlib release, Unix builds should have been unaffected.
Your error indeed seems like the one I get if I forget zlib entirely. But I sometimes receive an error if I do not add zlib to LD_LIBRARY_PATH, so it may be worth trying to preempt that. A minimal shell might look like:
I was unable to build your package because you have a base constraint ^>=4.17.2.1, but you also have a dependency on servant-event-stream, for which no version supports base >4.15. How do you build this project normally?
I’m currently reading and trying out the possible solutions above, but I normally just run cabal build --allow-newer=all, as some dependencies won’t build otherwise because of version mismatch. Can not remember which packages exactly, but some are more troublesome than others